• Word Macro to Determine if Specific Printer is Installed

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Word Macro to Determine if Specific Printer is Installed

    Author
    Topic
    #506979

    Anybody have macro code for Word 2010 and above to determine if a specific printer is installed? I have a .DOT file that I created at the office and it sets office printers but I also use the file at home with a different printer. I tried using ONERROR to pass over the macro code that sets a printer, but it’s not really an error when it encounters the code to set the printer (at least I don’t think this is working). So, I thought I’d try to determine if the printer exists and bypass the set printer code if it doesn’t. Thanks!

    Viewing 0 reply threads
    Author
    Replies
    • #1578321

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

      • #1578327

        See: http://www.cpearson.com/Excel/GetPrinters.aspx

        Thanks. That is very helpful code. I ran across that yesterday and thought it was a bit complicated, but it does work great. I also ran across some suggestions here: http://www.ozgrid.com/forum/showthread/?t=10081. I combined the two a bit to come up with my test code to determine if the printer is installed.

        However, I may have been overthinking this or asking the wrong question. I thought I needed to determine if a printer was installed before proceeding, but after messing around with all the above code I started thinking that maybe all I needed was something like this:

        Code:
        If ActivePrinter = “\DTCHYB-NCCH008PRT22789-RIC5210” Then
                GoTo SkipPrinter
            Else
                GoTo SkipLoop
            End If

        I think when I switch between office and home all I need to do is check to see if the above printer is the active printer. If it’s not, then I am home. I’m gonna try this later at home (at the office right now).

        Thanks!

        -Rich

        • #1578424

          A key difference between your code and the code on the Pearson website, is that the latter tests which printers are installed (which is what you said you wanted to do), whereas your code only tests which printer is active. Testing which printers are installed allows you to make any one of them active. Thus, you might start off by testing the ActivePrinter and, if it’s not the one you want, test the installed set to see if it’s available and, if so, activate it, else do something different.

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

    Viewing 0 reply threads
    Reply To: Word Macro to Determine if Specific Printer is Installed

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

    Your information: