Automating printing existing PDF documents using VBA
Hi,
I have a mixture of Word/PDF documents which I would like to print in the right sequence using MS Word VBA. Everything works fine. My code for printing PDF documents using DDE is as follows:
Dim RetVal
Dim chanNo
'Open Adobe Acrobat
RetVal = Shell("C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Acrobat.exe", vbHide)
chanNo = DDEInitiate("AcroViewA21", "Control")
'File is opened and displayed with DocOpen
DDEExecute chanNo, "[DocOpen(""" & myDoc & """)]"
'Print the file
DDEExecute chanNo, "[FilePrintTo(""" & myDoc & """,""" & myPrinter & ""","""")]"
'Close PDF file
DDEExecute chanNo, "[DocClose(""" & myDoc & """)]"
'Close Acrobat
DDEExecute chanNo, "[AppExit( )]"
Where myDoc and myPrinter need to be defined.
I have read that DDE is now old technology and is only available for backwards compatibility and that OLE should be used instead. I am not a programmer, so I'm not sure how important this is.
Can someone please provide an OLE solution to do the same task, just to ensure this is futureproof. In particular, it is important to be able set the printer.
Any help would be greatly appreciated. Thanks!
