Sub ConvertWordToPDF() Dim folderPath As String Dim wordFile As String Dim pdfFile As String Dim wordApp As Object folderPath = "C:\Users\JIAHE\Desktop\Output\" Set wordApp = CreateObject("Word.Application") wordApp.ScreenUpdating = False wordFile = Dir(folderPath & "*.doc*") Do While wordFile <> "" pdfFile = Left(wordFile, Len(wordFile) - 4) & ".pdf" wordApp.Documents.Open folderPath & wordFile wordApp.ActiveDocument.ExportAsFixedFormat OutputFileName:= _ folderPath & pdfFile, ExportFormat:=17, OpenAfterExport:=False wordApp.ActiveDocument.Close wordFile = Dir() Loop wordApp.Quit Application.ScreenUpdating = True
End Sub
|