|
-
Aug 24th, 2007, 10:29 AM
#1
Thread Starter
New Member
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?
-
Aug 25th, 2007, 09:54 AM
#2
New Member
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
-
Aug 27th, 2007, 09:19 AM
#3
Thread Starter
New Member
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?
-
Mar 5th, 2009, 12:30 PM
#4
New Member
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
-
Oct 4th, 2011, 02:42 PM
#5
New Member
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
-
Apr 6th, 2016, 05:01 PM
#6
Registered User
Re: Printing to a Network Printer
 Originally Posted by Aerious
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.
-
Apr 7th, 2016, 10:07 AM
#7
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|