View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default printer port assignment in macro

You may never find a legitimate port. I always like to make sure On Error
Resume Next only refers to a specific area of code - otherwise it can mask
true errors and makes debugging very difficult.

--
Regards,
Tom Ogilvy


"DaveAlbany" wrote:

thank you very much!

what is the purpose and need of the two On Error Goto 0 commands though?

"Tom Ogilvy" wrote:

Use something like:

for i = 1 to 9
err.clear
On error resume Next
Application.ActivePrinter = "printername on Ne0" & i & ":"
if err.Number = 0 then exit for
On error goto 0
Next
On Error goto 0

--
Regards,
Tom Ogilvy

"DaveAlbany" wrote:

I want to access a network printer via a macro and am successful as long as I
know the current address of the printer for the specific network user. The
command Application.ActivePrinter = "printername on Ne0x:" works just fine -
except the printername is different on each computer and the Ne0x: (port?)
changes from computer to computer, and in fact changes from time to time on a
single computer. How can I code this so it will work from multiple computers
all the time?