'Error on VBA during conversion from PDF to Doc file in MS Access
I am try to convert MS Access Report "Premier Practice" to PDF file "Premier Practice.pdf" than convert to Premier Practice.doc. Finally open Premier Practice.doc I am getting error: Error 462 in VBA : remote server machine not found
and sometime I get this error: Run time error -'2147023170(8000706be)'Automation Error: The remote procedure call failed - it highlights ChangeFileOpenDirectory "C:\Users\Owner\Documents"
Below is VBA Code in MS Access:
DoCmd.OutputTo acOutputReport, "Premier Practice", acFormatPDF, "C:\Users\Owner\Documents\Premier Practice.PDF"
DoEvents
Dim MyObj As Object, MySource As Object, file As Variant
file = Dir("C:\Users\Owner\Documents\Premier Practice.pdf") 'pdf path
Do While (file <> "")
ChangeFileOpenDirectory "C:\Users\Owner\Documents\"
Documents.Open FileName:=file, ConfirmConversions:=False, ReadOnly:= _
False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
"", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
Format:=wdOpenFormatAuto, XMLTransform:=""
ChangeFileOpenDirectory "C:\Users\Owner\Documents\" 'path for saving word
ActiveDocument.SaveAs2 FileName:=Replace(file, ".pdf", ".doc"), FileFormat:=wdFormatXMLDocument _
, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, CompatibilityMode:=15
ActiveDocument.Close
file = Dir
Loop
DoEvents
DoCmd.RunMacro "Open Word"
End Sub
DoCmd.RunMacro "Open Word"
Dim WordApp As Word.Application
Dim WordDoc As Word.Document
Set WordApp = CreateObject("Word.Application")
Set WordDoc = WordApp.Documents.Open _
("C:\Users\Owner\Documents\Premier Practice.doc")
WordApp.Visible = True
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|