用LotusScript举个例子:
①、先创建word对象:
On Error Resume Next
Set wordapp = GetObject("", "Word.Application.8")
If Isempty(wordapp) Then
Set wordapp = CreateObject("Word.Application.8")
If Isempty(wordapp) Then
Set wordapp = GetObject("","WPS.Application") '兼容WPS
If Isempty(wordapp) Then
Print "请先安装WORD"
Exit Sub
End If
End If
End If
②、然后对word对象进行判断是否已被保护:
If wordapp.ActiveDocument.ProtectionType = wdNoProtection Then
Call wordapp.ActiveDocument.Protect(保护类型, True, "密码")
else
wordapp.ActiveDocument.Unprotect ("密码")
End If
保护类型可查看word官网:ProtectionType 属性