请参: '* +++++++++++++++++++++++++++++
'* Created By I Love You_Word!@ExcelHome 2005-3-18 5:49:08
'仅测试于System: Windows NT Word: 10.0 Language: 2052
'^The Code CopyIn [ThisDocument-ThisDocument]^'
'* -----------------------------Sub ExampleToDocumnetProtectOne()
With ActiveDocument
'如果文档未设置打开文档密码和未设写权限密码则进行设置
If .HasPassword = False And .WriteReserved = False Then
.Password = "Test"
.WritePassword = "123"
.Save
End If
End With
End Sub
'----------------------
Sub ExampleToDocumnetProtectTwo()
'利用另存为,进行设置打开和写权限密码
ActiveDocument.SaveAs FileName:="TestForPassword", Password:="Test", WritePassword:="123"
End Sub
'----------------------
Sub CanCelPassword()
With ActiveDocument
If .HasPassword And .WriteReserved Then
.Password = "" '取消密码
.WritePassword = "" '取消密码
.Save
End If
End With
End Sub
'---------------------- |