Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    Best Regards,

    Luke

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts
    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.
    Wendell

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •