利用vbs指令碼將word文件轉換為pdf

卓能文發表於2024-07-06
Set wrd = GetObject(, "Word.Application")
wrd.Visible = False

path = "D:\列印\評分表word\"
wdFormatPDF = 17
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(path)
For Each file in folder.Files
    If InStr(file.Name, ".docx") > 0 Then
        wrd.Documents.Open file.Path
        wrd.ActiveDocument.SaveAs2 file.Path & ".pdf", wdFormatPDF
        wrd.ActiveDocument.Close
    End If
Next

wrd.Quit
Set wrd = Nothing

相關文章