Word轉PDF的VBA腳本


將以下內容復制粘貼在一個txt中,修改txt后綴為“.vbs”

On Error Resume Next

Const wdExportFormatPDF = 17

Set oWord = WScript.CreateObject("Word.Application")

Set fso = WScript.CreateObject("Scripting.Filesystemobject")

Set fds=fso.GetFolder(".")

Set ffs=fds.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

odoc.Close wdDoNotSaveChanges

End If

Next

   

oword.Quit

Set oDoc=Nothing

Set oWord =Nothing

MsgBox "Word文件已全部轉換為PDF格式!"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM