ConvertToPdf.vbs:
On Error Resume Next
Const wdExportFormatPDF = 17
Set oWord = WScript.CreateObject("Word.Application")
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
Function GetSubFolders(currentFolderFullPath)
Set fso = CreateObject("Scripting.FileSystemObject")
Set currentFolder = fso.GetFolder(currentFolderFullPath)
Set subFolderSet = currentFolder.SubFolders
For Each subFolder in subFolderSet
'MsgBox "subFolder.Path=" & subFolder.Path
GetSubFolders = subFolder.Path & ";" & GetSubFolders(subFolder.Path) & GetSubFolders
Next
End Function
Set fds=fso.GetFolder(".")
Set subFolderSet = fds.SubFolders
For Each subFolder in subFolderSet
Set ffs=subFolder.Files
For Each ff In ffs
If (LCase(Right(ff.Name,4))=".doc" Or LCase(Right(ff.Name,4))="docx" ) And Left(ff.Name,1)<>"~" Then
Set oDoc=oWord.Documents.Open(ff.Path)
odoc.ExportAsFixedFormat Left(ff.Path,InStrRev(ff.Path,"."))&"pdf",wdExportFormatPDF
If Err.Number Then
MsgBox Err.Description
End If
End If
Next
Next
odoc.Close
oword.Quit
Set oDoc=Nothing
Set oWord =Nothing
MsgBox "Word文件已全部转换为PDF格式 !"
PDF批量处理
于 2021-10-27 11:57:08 首次发布