RunTime Error 462 while converting word docx to PDF

SydneyBuoy

New Member
Joined
Sep 9, 2019
Messages
2
'******* 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.
 

Forum statistics

Threads
1,085,419
Messages
5,383,555
Members
401,836
Latest member
Bweston07

Some videos you may like

This Week's Hot Topics

Top