• Specify Printer on Word Print from VBA

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Specify Printer on Word Print from VBA

    Author
    Topic
    #464801

    Hi,

    Traditionally we have had the print dialog box come up to allow the users to select the printer they wish to send the document to.

    We are now producing PDF’s from vba and need to specify the PDF printer via vba as the one for the vba code for the word mail merge to use.

    The vba code so far looks:

    Set objWord = New Word.Application
    ‘Letter document would be open
    Set objletter = objWord.Documents.Open(strletterpath & strworddoc)
    objletter.MailMerge.OpenDataSource (strletterpath & strletterfile)
    objletter.MailMerge.Destination = wdSendToNewDocument ‘normally print
    objletter.MailMerge.Execute
    ‘not normally here
    objWord.Visible = True
    objWord.ActiveDocument.PrintOut

    How do I get it to come out on a particulr printer (i.e the pdf printer that is not the default printer)

    Any ideas?

    Viewing 1 reply thread
    Author
    Replies
    • #1191507

      If you check the object model for Word, you should find that you can specify a printer as a part of the
      objWord.Activedocument.PrintOut
      statement, and you will also need to specify a file location where the PDF document is to be stored.

    • #1191508

      Use something like this

      Dim strPrinter As String
      ‘ Get the current printer
      strPrinter = objWord.ActivePrinter
      ‘ The easiest way to get the correct name is to record a macro in Word
      objWord.ActivePrinter = “PDF Printer”

      ‘ The original line to print the document
      objWord.Activedocument.PrintOut

      ‘ Restore the original printer
      objWord.ActivePrinter = strPrinter

    Viewing 1 reply thread
    Reply To: Specify Printer on Word Print from VBA

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: