'* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2007-3-21 18:53:41 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0186^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Private Sub Document_Close() Dim i As Section, myPW As String myPW = "Word2003" Me.Unprotect myPW For Each i In Me.Sections i.ProtectedForForms = True Next Me.Protect Type:=wdAllowOnlyFormFields, Password:=myPW Me.Save End Sub '----------------------
Private Sub Document_Open() Me.ActiveWindow.Visible = False UserForm1.Show End Sub '---------------------- '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2007-3-21 18:53:55 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0187^The Code CopyIn [用户窗体-UserForm1]^' '* ----------------------------- Option Explicit Const myPW As String = "Word2003" Private Sub CommandButton1_Click() With ThisDocument Select Case Me.TextBox1.Text Case "11111", "22222", "33333", "44444", "55555", "66666", "77777" .Unprotect myPW .Sections(1).ProtectedForForms = False .Sections(2).ProtectedForForms = True .Protect Type:=wdAllowOnlyFormFields, Password:=myPW .ActiveWindow.Visible = True Case "88888", "99999", "00000" .Unprotect "Word2003" .Sections(1).ProtectedForForms = True .Sections(2).ProtectedForForms = False .Protect Type:=wdAllowOnlyFormFields, Password:=myPW .ActiveWindow.Visible = True Case Else MsgBox "请确认您的密码无误!", vbInformation .Close False End Select End With Unload Me End Sub '----------------------
Private Sub TextBox1_Change() Me.CommandButton1.Enabled = True Me.CommandButton2 = True Me.CommandButton1.Default = True End Sub '----------------------
Private Sub UserForm_Initialize() Me.CommandButton1.Enabled = False Me.CommandButton2.Enabled = False End Sub '----------------------
G9sDS2iu.rar
(12.83 KB, 下载次数: 18)
[此贴子已经被作者于2007-3-21 18:55:45编辑过] |