+ Reply to Thread
Results 1 to 3 of 3

VBA print code to pop up msgbox if I choose a non existing printer

  1. #1
    Registered User
    Join Date
    07-27-2013
    Location
    Peru
    MS-Off Ver
    Excel 2003
    Posts
    24

    VBA print code to pop up msgbox if I choose a non existing printer

    Hello
    I´m using this code to select a specific printer:
    Application.Dialogs(xlDialogPrinterSetup).Show

    What I want the application to do is to pop up a msgbox with the msg "select another printer" if I choose a printer that's not available.

    żany genius can help me?

    Regards
    Claudio

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA print code to pop up msgbox if I choose a non existing printer

    I'd suggest trapping the error when you try to print to the unavailable printer and then using the msgbox. For example, something along the lines of:
    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,860

    Re: VBA print code to pop up msgbox if I choose a non existing printer

    Hi loroverde,

    Thank you for pointing out function 'Application.Dialogs(xlDialogPrinterSetup).Show'. The plus side is it's a one liner. The minus side is that it doesn't suit your needs.

    See the attached file, which identifies all printers (tested in Excel 2003 on Vista 32 bit system), whether they are active or not, and also identifies the default printer. It will also set the Default Printer. It is a lot more than a 'one liner', but does the job for me.

    I use these routines to populate a ComboBox on a UserForm in my applications to enable a User to select a 'Default Printer'. I also create a list of printers to EXCLUDE if they are in the list, so the ComboBox won't be cluttered with junk.

    I hope this helps.

    Lewis

    The code is attached for reference, but I suggest downloading the file, to see how it works without modiifying anything for your implementation.


    To use the following code a Sheet named "Printers" is REQUIRED.
    Module A
    Please Login or Register  to view this content.

    Module B
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by LJMetzger; 01-14-2014 at 01:19 PM. Reason: Forgot download file.

+ 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. How Do I Code to print to a Printer by the Printer Name?
    By rkjudy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2013, 05:28 PM
  2. [SOLVED] Simple MSGBOX which can work with any existing code
    By omega0010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-23-2013, 05:18 AM
  3. Print to a specific Printer and also choose the pages to be printed.
    By aadeshgandhi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2013, 12:07 PM
  4. Adjust existing macro to print to default printer
    By Sanceus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-15-2012, 10:32 AM
  5. VBA for print if cell contains, then choose printer. Have code just need advice.
    By lukestkd in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2012, 08:39 PM

Tags for this Thread

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