Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default printer port assignment in macro

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default printer port assignment in macro

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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default printer port assignment in macro

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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printer Using USB Port Slows Page Setup Stu B Excel Discussion (Misc queries) 3 April 22nd 10 12:45 PM
Capturing Data from a Com Port or Printer Port Newby :) Excel Programming 3 August 19th 05 01:54 PM
VBA to change Button Macro assignment Ken Loomis Excel Programming 2 August 6th 05 05:47 PM
Macro assignment disappears duuxxyy Excel Programming 0 June 30th 05 09:30 AM
Relative Macro Assignment esskaykay Excel Programming 3 April 25th 04 10:55 PM


All times are GMT +1. The time now is 05:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"