- 2021-01-01 20:40
categories:
- 编程
新建文本,粘贴复制,另存为.vbs的文件,保存的时候注意将文件编码选择ANSI
On Error Resume NextConst wdExportFormatPDF = 17Set oWord = WScript.CreateObject("Word.Application")Set fso = WScript.CreateObject("Scripting.Filesystemobject")Set fds=fso.GetFolder(".")Set ffs=fds.FilesFor Each ff In ffsIf (LCase(Right(ff.Name,4))=".doc" Or LCase(Right(ff.Name,4))="docx" ) And Left(ff.Name,1)<>"~" ThenSet oDoc=oWord.Documents.Open(ff.Path)odoc.ExportAsFixedFormat Left(ff.Path,InStrRev(ff.Path,"."))&"pdf",wdExportFormatPDFIf Err.Number ThenMsgBox Err.DescriptionEnd IfEnd IfNextodoc.Closeoword.QuitSet oDoc=NothingSet oWord =NothingMsgBox "Word文件已全部轩换为PDF格式!"
**
