+ Reply to Thread
Results 1 to 7 of 7

Selecting Default Printer in a Macro

  1. #1
    Forum Contributor
    Join Date
    09-28-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    141

    Selecting Default Printer in a Macro

    Hi everyone,

    I have a form control set up as a PRINT button.

    Normally, if I click it, it prints the worksheet from my active printer, which is also my default printer. This is my desired outcome.

    However, if i have saved a PDF of the worksheet before using the PRINT button, my PDF printer will be the current active printer. Therefore, clicking my PRINT button will create a PDF as opposed to sending the worksheet to my default printer.

    Can anyone suggest a way that I can avoid this happening? I don't want to have to specify the default printer's name in the macro as it will be used on ther user's systems who would obviously have different brands/models of printers.

    Any help appreciated.

    Andy

  2. #2
    Forum Contributor
    Join Date
    05-12-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    266

    Re: Selecting Default Printer in a Macro

    maybe you can use this in your code:
    Please Login or Register  to view this content.

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Selecting Default Printer in a Macro

    If different users are involved you would need an API-call to determine the default printer and set accordingly.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Forum Contributor
    Join Date
    09-28-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    141

    Re: Selecting Default Printer in a Macro

    Thanks SjonR, but this generates a dialog box which I would like to avoid if possible.

  5. #5
    Forum Contributor
    Join Date
    09-28-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    141

    Re: Selecting Default Printer in a Macro

    Thanks bakerman2, what's an API call and how do i do this?

  6. #6
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Selecting Default Printer in a Macro

    Good afternoon aglawrence

    You don't want to get involved in API calls and the like. Really.

    What you could do is run a little macro like this on opening the file :
    Please Login or Register  to view this content.
    This will put the name of the currently active printer in a cell, to use later, or whenever you need it. This cell could be contained in a hidden sheet.

    Then use this line in front of your current macro to ensure the print goes to the correct printer :
    Please Login or Register  to view this content.
    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

  7. #7
    Forum Contributor
    Join Date
    09-28-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    141

    Re: Selecting Default Printer in a Macro

    Thanks DominicB, that's a great solution!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to first try default printer, otherwise select one
    By ErikB85 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-09-2017, 06:50 PM
  2. [SOLVED] Solution to changing Default printer code when printer changes
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 10-28-2016, 03:12 PM
  3. [SOLVED] Macro to print to the default printer
    By Alves76 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-22-2013, 05:47 AM
  4. [SOLVED] Selecting a Printer from a Macro
    By EdWoods in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-04-2013, 08:13 PM
  5. macro to print 2 copies to default printer, then 1 copy to Adobe PDF printer
    By jwright650 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-26-2011, 01:07 PM
  6. Using a non-default printer in a macro
    By bgreen in forum Excel General
    Replies: 3
    Last Post: 06-15-2009, 05:33 PM
  7. macro print to default printer help
    By st24rsap in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2009, 07:22 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1