SydneyBuoy
New Member
- Joined
- Sep 9, 2019
- Messages
- 4
'******* EmpFolder is a Global Variable containing Folder Path *************************
Sub BatchConvertDocxToPDF()
Dim objDoc1 As Document
Dim strFile As String, strFolder As String
'Initialization
strFolder = EmpFolder & ""
strFile = Dir(strFolder & "*.docx", vbNormal)
'Precess each file in the file folder and convert them to pdf.
While strFile <> ""
Set objDoc1 = Documents.Open(Filename:=strFolder & strFile)
objDoc1.ExportAsFixedFormat _
OutputFileName:=Replace(objDoc1.FullName, ".docx", ".pdf"), _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportAllDocument, Item:=wdExportDocumentContent
objDoc1.Close
strFile = Dir()
Wend
End Sub
The following line is highlighted as the error "Set objDoc1 = Documents.Open(Filename:=strFolder & strFile)". Run Time Error 462: The Remote Server Machine does not exist or is unavailable.
Sub BatchConvertDocxToPDF()
Dim objDoc1 As Document
Dim strFile As String, strFolder As String
'Initialization
strFolder = EmpFolder & ""
strFile = Dir(strFolder & "*.docx", vbNormal)
'Precess each file in the file folder and convert them to pdf.
While strFile <> ""
Set objDoc1 = Documents.Open(Filename:=strFolder & strFile)
objDoc1.ExportAsFixedFormat _
OutputFileName:=Replace(objDoc1.FullName, ".docx", ".pdf"), _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, _
Range:=wdExportAllDocument, Item:=wdExportDocumentContent
objDoc1.Close
strFile = Dir()
Wend
End Sub
The following line is highlighted as the error "Set objDoc1 = Documents.Open(Filename:=strFolder & strFile)". Run Time Error 462: The Remote Server Machine does not exist or is unavailable.