Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Tacoma, Washington, USA
    Posts
    408
    Thanks
    0
    Thanked 2 Times in 2 Posts

    How to identify printer, then take action based on printer identity

    Everyone on our network has access to a shared startup template that includes a macro for selecting which tray to send their document. This worked well for us over the years because everyone was using the same printer and thus the same print driver.

    Back in February a new printer model was added to network. At that time I posted (here) asking for assistance in working out a macro that would identify the print driver and then based on the print driver point the user to the correct tray select macro. A solution wasn't found. This turned out to be the only new printer of its kind so instead I added a custom macro on those user's computers specific to that different printer.

    Here we are a few months later, with 17 new printers of a third model type. The main network-shared tray select macro doesn't work with these new printers. No surprise there. Revisiting this, is it possible for the macro to recognize the printer by name and then point the user to the correct tray select macro? Here's what I have so far:

    Code:
    Sub IdentifyPrinter()
        On Error GoTo -1: On Error GoTo Trap
    
        If Application.ActivePrinter = "\\CLIENTSRVR\HP000473" Then
            MsgBox ("4350 is Active Printer.")
            frmTraySelect4350.Show
        ElseIf STDPrinter = "HP000538" Then
            MsgBox ("M602n is Active Printer.")
            frmTraySelectM602.Show
        Else
            MsgBox ("Unable to Determine Active Printer.")
        End If
        
    GoTo NoMore
    
    NoMore:
        MsgBox ("Complete.")
        GoTo Complete
        
    OutOfHere:
        MsgBox ("Cancelled!")
        GoTo Complete
    
    Trap:
    If Err.Number = 102 Then
        MsgBox ("An Error Occurred!")
        Err.Number = 0
        GoTo Complete
    ElseIf Err.Number = 509 Then
        MsgBox ("An Error Occurred!")
        Err.Number = 0
        GoTo Complete
    Else
        Error Err.Number
    End If
    
    Complete:
                
    End Sub
    To come up with the printer name I ran a new macro to track a printer change. However, the macro isn't recognizing the printer by name. These printers are all IP based. Maybe there's a different way to identify them? They're HP Laserjet 4350dtn and HP Enterprise Laserjet M602n, respectively. Suggestions?
    Daisy

  2. #2
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    667
    Thanks
    3
    Thanked 19 Times in 18 Posts
    Daisy,

    I wrote a macro that looks at the current printer and determines which trays are available. I used several valuable articles by MVP Jonathan West as inspiration -- starting HERE.

    Using vba, you make use of Windows API calls to query the printers for information about them (such as trays). Once your macro has determined the trays available, you can make use of them. BTW, you'll also find a reference at the top of this article to a product called Tray Selector (which I have not used), which may be of interest to you.

    Thanks to Jonathan's articles I was able to craft a fairly complex macro that could access any printer visible to a given computer and address any trays the printer knows it has.

    Does this get you anywhere near your destination?

    Kim

  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,243
    Thanks
    202
    Thanked 796 Times in 729 Posts
    Kim,

    Thanks for a great link! Unfortunately, it appears that the site is no longer posting new content. I was thinking of subscribing until I noticed this. Do you happen to know if they plan to resume?
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  4. #4
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    667
    Thanks
    3
    Thanked 19 Times in 18 Posts
    RetiredGeek, you are welcome. I don't know about updates -- I never subscribed (which was a little short-sighted on my part, I think). It looks as if Dian has had life intervene, and that it's been a while since an update was posted.... I suspect she will start up again if she can.

    It's a *very* useful site anyway.

    Kim

  5. #5
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Tacoma, Washington, USA
    Posts
    408
    Thanks
    0
    Thanked 2 Times in 2 Posts
    I wrote a macro that looks at the current printer and determines which trays are available. I used several valuable articles by MVP Jonathan West as inspiration -- starting HERE.
    Brilliant! At last I can complete this project. It worked perfectly. I'll be rolling out the macro tomorrow (via startup template). Thank you!!
    Daisy

  6. #6
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    667
    Thanks
    3
    Thanked 19 Times in 18 Posts
    Fantastic! You're welcome!

    Kim

Posting Permissions

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