• 2021-01-01 20:40
      categories:
      - 编程

    新建文本,粘贴复制,另存为.vbs的文件,保存的时候注意将文件编码选择ANSI

    1. On Error Resume Next
    2. Const wdExportFormatPDF = 17
    3. Set oWord = WScript.CreateObject("Word.Application")
    4. Set fso = WScript.CreateObject("Scripting.Filesystemobject")
    5. Set fds=fso.GetFolder(".")
    6. Set ffs=fds.Files
    7. For Each ff In ffs
    8. If (LCase(Right(ff.Name,4))=".doc" Or LCase(Right(ff.Name,4))="docx" ) And Left(ff.Name,1)<>"~" Then
    9. Set oDoc=oWord.Documents.Open(ff.Path)
    10. odoc.ExportAsFixedFormat Left(ff.Path,InStrRev(ff.Path,"."))&"pdf",wdExportFormatPDF
    11. If Err.Number Then
    12. MsgBox Err.Description
    13. End If
    14. End If
    15. Next
    16. odoc.Close
    17. oword.Quit
    18. Set oDoc=Nothing
    19. Set oWord =Nothing
    20. MsgBox "Word文件已全部轩换为PDF格式!"

    **