Consulting

Results 1 to 6 of 6

Thread: Solved: Print to non-default printer

  1. #1

    Question Solved: Print to non-default printer

    I am looking to add some automatic printing at the end of an inport macro that I wrote. Using the search function of these forums I found what I thought was the exact answer to my problem, but I cannot figure out what I am doing wrong. I am trying to adapt the tips found in
    vbaexpress.com/kb/getarticle.php?kb_id=528

    The code that I have written (stripped down to the print portions) is as follows.
    [vba]
    Dim PrintUp as String 'Holds location of network printer upstairs
    Dim PrintPDF as String 'Name of PDF printer

    PrintUp = "\\ fpserver-dc\ome-cm4520" '(a space added after "\\" to avoid auto linking that is keeping me from making post)
    PrintPDF = "Adobe PDF"

    Application.ActivePrinter = PrintUp
    sheets(2).printout
    [/vba]

    I will eventually add in code that will print to the correct place depending on what conditions are met... but as it stands it always prints to my default printer... i am starting to waste more paper that I'd like.

    Secondly I am not exactly sure what to put down for my PDF printer, that is the title of it in my printers window.

    If it makes a difference I am using Vista and the display name of my upstairs printer is "OME-CM4520 on FPSERVER-DC"

  2. #2
    VBAX Mentor Brandtrock's Avatar
    Joined
    Jun 2004
    Location
    Titonka, IA
    Posts
    399
    Location
    Your code as posted is telling it to print to the printer upstairs. Is that the default printer you are talking about?

    Does it still print to the same place if you change the Application.ActivePrinter line to:

    [vba]Application.ActivePrinter = PrintPDF[/vba] or not?

    You can change your printer settings in Windows Control Panel to Pause Printing for the upstairs printer to save on paper. It will show the print jobs sent to the printer and you can cancel them without printing, if that helps.

    Regards,
    Brandtrock




  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Brian,
    Welcome to VBAX
    I've modified the code in this file
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    I am sorry that I haven't been as clear as I needed to be. The upstairs printer is not my default printer. My default printer is in my office with me downstairs.

    Also, I used the kb I mentioned as a guide to change active printers, but I did not intend to make a button with my code.

    I tried downloading and running the code in your file mdmac, but I got an error "Method 'ActivePrinter' of object '_Application' failed" This is on the line of code
    Application.ActivePrinter = GetPrinterKey("PDFCreator")

    Thank you ffor the tip about pausing the printer. it will make things much easier on me as I try to figure this out.

    Brian

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Brian
    Record a macro changing to your upstairs printer. You should get something like
    ActivePrinter = UpstairsPrinter on Ne04:
    Use the first part instead of PDFCreator in my code. The "on Ne04:" is returned by the complicated stuff. Basically, printers are assigned to Ne00:, Ne01: etc. in alphabetical order.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    Using record macro to find the NE## info worked great! Don't know why I hadn't tried that earlier. thank you!

Posting Permissions

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