Results 1 to 4 of 4
  1. #1
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post

    Word Macro to Determine if Specific Printer is Installed

    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!

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    3 Star Lounger rcbjr2's Avatar
    Join Date
    Jan 2001
    Location
    Matthews, NC
    Posts
    279
    Thanks
    6
    Thanked 1 Time in 1 Post
    Quote Originally Posted by macropod View Post
    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.php?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-NCCH008\PRT22789-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

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    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
    [MS MVP - Word]

  5. The Following User Says Thank You to macropod For This Useful Post:

    rcbjr2 (2016-09-21)

Posting Permissions

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