Results 1 to 7 of 7

Thread: Printing to a Network Printer

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    2

    Printing to a Network Printer

    I am working with excel VBA and need to print a form to a set network printer and not the defalt printer. Many people on our network use this excel form and the defalt printer can very but I want all the printing of this form to be at a set network printer. I am using this code to print now "ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate:=True". Can some one help me?

  2. #2
    New Member
    Join Date
    Aug 2006
    Posts
    12

    Re: Printing to a Network Printer

    Try something like this,I got the code from recording the macro
    Code:
        Application.ActivePrinter = "\\Daves\Lexmark 810 Series on Ne10:"
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
            "\\Daves\Lexmark 810 Series on Ne10:", Collate:=True

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    2

    Re: Printing to a Network Printer

    Ya that worked good. But is there a way to find out my printers exact name. I can get most all of it but that last part after the Ne? thing. Is there a convention I should under stand or thomthing?

  4. #4
    New Member
    Join Date
    Mar 2009
    Posts
    1

    Re: Printing to a Network Printer

    Good luck. I have had no luck figuring out a way to automatically figure out the "NE" number of a printer. I think it's absurd that you have to have that number anyway.

    My problem is I have multiple people across the network using these forms, and they all have different NE numbers for the same printers. The NE is assigned when the printer is installed. So if you go back, uninstall all of their printers, then reinstall them all in the same order you're fine. But if you delete one and reinstall it at some point, that persons printer NE numbers are all messed up.

    Anybody able to help on this one out there?
    Mark

  5. #5
    New Member
    Join Date
    Oct 2011
    Posts
    2

    Re: Printing to a Network Printer

    I realize that this post is 2 years old, but also I just found it today and it solved my problem, so I will solve the problem they had...

    This assumes it is printing to non-default printer.

    Code:
        oldprinter = Application.ActivePrinter
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne00:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne01:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne02:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne03:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne04:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne05:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne06:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne07:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne08:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne09:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne10:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne11:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne12:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne13:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne14:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne15:"
        ActiveWindow.Selection.PrintOut Copies:=1
        Application.ActivePrinter = oldprinter
    In fact that is pretty darn ugly so I just got this to work too (use as you like)

    Code:
        oldprinter = Application.ActivePrinter
        
        For i = 0 To 15
           curNePrint = Format(i, "00")
           On Error Resume Next
              Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne" & curNePrint & ":"
        Next i
        
    
        ActiveWindow.Selection.PrintOut Copies:=1
        Application.ActivePrinter = oldprinter
    Thanks
    ~Aerious

  6. #6
    Registered User
    Join Date
    Apr 2016
    Posts
    1

    Thumbs up Re: Printing to a Network Printer

    Quote Originally Posted by Aerious View Post
    I realize that this post is 2 years old, but also I just found it today and it solved my problem, so I will solve the problem they had...

    This assumes it is printing to non-default printer.

    Code:
        oldprinter = Application.ActivePrinter
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne00:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne01:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne02:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne03:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne04:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne05:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne06:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne07:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne08:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne09:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne10:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne11:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne12:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne13:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne14:"
        On Error Resume Next
            Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne15:"
        ActiveWindow.Selection.PrintOut Copies:=1
        Application.ActivePrinter = oldprinter
    In fact that is pretty darn ugly so I just got this to work too (use as you like)

    Code:
        oldprinter = Application.ActivePrinter
        
        For i = 0 To 15
           curNePrint = Format(i, "00")
           On Error Resume Next
              Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne" & curNePrint & ":"
        Next i
        
    
        ActiveWindow.Selection.PrintOut Copies:=1
        Application.ActivePrinter = oldprinter
    Thanks :)
    ~Aerious
    Thanks Aerious... athough this post is old it is still helping others in 2016. I have used this and it works great.

  7. #7
    New Member
    Join Date
    Oct 2011
    Posts
    2

    Re: Printing to a Network Printer

    Happy to be of help.

    Wanted to add that over the years I have seen the need to (properly) add

    On Error Goto 0 after the final line. This resets the error handling back to 'normal' which will help prevent unintended consequences of possible errors further down in the code.


    Code:
    oldprinter = Application.ActivePrinter
        
        For i = 0 To 15
           curNePrint = Format(i, "00")
           On Error Resume Next
              Application.ActivePrinter = "\\ServerName\ZDesigner S4M-203dpi ZPL on ne" & curNePrint & ":"
        Next i
        
        ActiveWindow.Selection.PrintOut Copies:=1
        Application.ActivePrinter = oldprinter
        On Error Goto 0
    ~Aerious

Posting Permissions

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



Click Here to Expand Forum to Full Width