|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub word多个文档批量添加打开密码尚待完善()
- Rem 需要选择需要添加密码的多个文件
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- With Application.FileDialog(msoFileDialogFilePicker)
- .Filters.Clear
- .Filters.Add "Word Files", "*.do*"
- If .Show = -1 Then
- For Each oItem In .SelectedItems
- Documents.Open (oItem)
- With ActiveDocument
- '此处放置代码内容
- 'i = i + 1
- .SaveAs FileName:=ActiveDocument.FullName, Password:="123" '打开密码
- '.Protect Type:=wdAllowOnlyFormFields, Password:="123" '文档保护限制编辑,但不是打开密码
- .Close True
- 'MsgBox ActiveDocument.FullName
- ' .Save
- '.Close
- End With
- Next '继续下一个文件
- Else
- Exit Sub
- End If
- End With
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- 'MsgBox i
- MsgBox "操作完毕!"
- End Sub
复制代码 我写代码试了一下,但此代码失效,不能顺利给多个word文档添加“123”的密码,请指教^_^
|
|