View Single Post
 
Old 11-22-2021, 03:35 PM
PhilTilson PhilTilson is offline Windows 10 Office 2016
Novice
 
Join Date: Nov 2021
Posts: 4
PhilTilson is on a distinguished road
Default Correct syntax for printing from VBA

Could somebody (Graham?) please tell me where I am going wrong with the syntax in this snippet:

Code:
    curPtr$ = Application.ActivePrinter
    Application.ActivePrinter = "Microsoft Print to PDF"
    ActiveDocument.PrintOut False, False, 0, txtFilename, 0, 0, 0, 1, 0, 0, True
    Application.ActivePrinter = curPtr$
The intention is clearly to print the whole of the current document to a .pdf file, given the name in txtFilename, but I just get a 'type mismatch' error on the third line.

Phil
Reply With Quote