 
- 帖子
- 191
- 积分
- 222
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2012-12-15
|
回复 5# yu2n
老师,这个太复杂了,简单一点,我通过其他代码改过来,批量加打开密码,到了Set wk=EAPP.Documents.Open(FSOFile)这一步通不过,请指正!
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
Dim objShell,objFolder,FolderPath,PW,wk,EAPP,FSO,FSOFolder,FSOFile
'获取Excel文件所在文件夹路径
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, "Select a folder:", OPTIONS,"")
If objFolder Is Nothing Then
Wscript.Quit
End If
FolderPath =objFolder.Self.Path
PW=Inputbox("请输入密码","批量添加密码")
if len(pw)=0 then Wscript.Quit
Set EAPP=CreateObject("Word.Application")
Set FSO=CreateObject("Scripting.FileSystemObject")
Set FSOFolder=FSO.GetFolder(FolderPath)
For Each FSOFile in FSOFolder.Files
If instr(Fsofile.Name,".doc") then
Set wk=EAPP.Documents.Open(FSOFile)
wk.PassWord=PW
wk.Close True
End If
EAPP.Quit
Next |
|