Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default printer exception, error handler, need to loop through network num

I don't know how to make this error handler loop through the possible network
numbers. The current network number is 02 for the printer but it can change
from 01 through 09. If they change it I would like it to loop through the
possibilities and then if it can't print give the user a warning.

Dim NetworkNumb as string
NetworkNumb = Ne02:

On Error GoTo errGetFile
' the network number can change, if error try another number
between 1 through 9
Application.ActivePrinter = "\\mynetworkregion\myprinter on " & NetworkNumb
Exit Sub
' handle possible printer exceptions
errGetFile
Application.ActivePrinter = "\\mynetworkregion\myprinter on
Ne01:"

Else
MsgBox " warning there is a problem with the printstring."
Resume Next


tia,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default printer exception, error handler, need to loop through network num

I didn't test this so fwiw:

Sub SetPrinter()
Dim Counter As Integer
On Error Resume Next
For Counter = 1 To 9
Application.ActivePrinter = _
"\\mynetworkregion\myprinter on Ne0" & Counter
If Err.Number = 0 Then Exit For
Next
If Err.Number < 0 Then MsgBox "No print"
End Sub


--
Jim
"Janis" wrote in message
...
|I don't know how to make this error handler loop through the possible
network
| numbers. The current network number is 02 for the printer but it can
change
| from 01 through 09. If they change it I would like it to loop through the
| possibilities and then if it can't print give the user a warning.
|
| Dim NetworkNumb as string
| NetworkNumb = Ne02:
|
| On Error GoTo errGetFile
| ' the network number can change, if error try another number
| between 1 through 9
| Application.ActivePrinter = "\\mynetworkregion\myprinter on " &
NetworkNumb
| Exit Sub
| ' handle possible printer exceptions
| errGetFile
| Application.ActivePrinter = "\\mynetworkregion\myprinter on
| Ne01:"
|
| Else
| MsgBox " warning there is a problem with the printstring."
| Resume Next
|
|
| tia,


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default printer exception, error handler, need to loop through network num

Sub SetPrinter()
Dim Counter As Integer
On Error Resume Next
For Counter = 1 To 9
Err.Clear ''<<< Added
Application.ActivePrinter = _
"\\mynetworkregion\myprinter on Ne0" & Counter
If Err.Number = 0 Then Exit For
Next
If Err.Number < 0 Then MsgBox "No print"
End Sub

--
Jim
"Jim Rech" wrote in message
...
|I didn't test this so fwiw:
|
| Sub SetPrinter()
| Dim Counter As Integer
| On Error Resume Next
| For Counter = 1 To 9
| Application.ActivePrinter = _
| "\\mynetworkregion\myprinter on Ne0" & Counter
| If Err.Number = 0 Then Exit For
| Next
| If Err.Number < 0 Then MsgBox "No print"
| End Sub
|
|
| --
| Jim
| "Janis" wrote in message
| ...
||I don't know how to make this error handler loop through the possible
| network
|| numbers. The current network number is 02 for the printer but it can
| change
|| from 01 through 09. If they change it I would like it to loop through the
|| possibilities and then if it can't print give the user a warning.
||
|| Dim NetworkNumb as string
|| NetworkNumb = Ne02:
||
|| On Error GoTo errGetFile
|| ' the network number can change, if error try another number
|| between 1 through 9
|| Application.ActivePrinter = "\\mynetworkregion\myprinter on " &
| NetworkNumb
|| Exit Sub
|| ' handle possible printer exceptions
|| errGetFile
|| Application.ActivePrinter = "\\mynetworkregion\myprinter on
|| Ne01:"
||
|| Else
|| MsgBox " warning there is a problem with the printstring."
|| Resume Next
||
||
|| tia,
|
|


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default printer exception, error handler, need to loop through network

thanks so much I guess its just a counter with a loop but I wouldn't have
guessed the clear. I got to learn error handling.

"Jim Rech" wrote:

Sub SetPrinter()
Dim Counter As Integer
On Error Resume Next
For Counter = 1 To 9
Err.Clear ''<<< Added
Application.ActivePrinter = _
"\\mynetworkregion\myprinter on Ne0" & Counter
If Err.Number = 0 Then Exit For
Next
If Err.Number < 0 Then MsgBox "No print"
End Sub

--
Jim
"Jim Rech" wrote in message
...
|I didn't test this so fwiw:
|
| Sub SetPrinter()
| Dim Counter As Integer
| On Error Resume Next
| For Counter = 1 To 9
| Application.ActivePrinter = _
| "\\mynetworkregion\myprinter on Ne0" & Counter
| If Err.Number = 0 Then Exit For
| Next
| If Err.Number < 0 Then MsgBox "No print"
| End Sub
|
|
| --
| Jim
| "Janis" wrote in message
| ...
||I don't know how to make this error handler loop through the possible
| network
|| numbers. The current network number is 02 for the printer but it can
| change
|| from 01 through 09. If they change it I would like it to loop through the
|| possibilities and then if it can't print give the user a warning.
||
|| Dim NetworkNumb as string
|| NetworkNumb = Ne02:
||
|| On Error GoTo errGetFile
|| ' the network number can change, if error try another number
|| between 1 through 9
|| Application.ActivePrinter = "\\mynetworkregion\myprinter on " &
| NetworkNumb
|| Exit Sub
|| ' handle possible printer exceptions
|| errGetFile
|| Application.ActivePrinter = "\\mynetworkregion\myprinter on
|| Ne01:"
||
|| Else
|| MsgBox " warning there is a problem with the printstring."
|| Resume Next
||
||
|| tia,
|
|



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default printer exception, error handler, need to loop through network

I will test it. The users get shut down and think the world ends when its
just the print string. thanks,

"Jim Rech" wrote:

I didn't test this so fwiw:

Sub SetPrinter()
Dim Counter As Integer
On Error Resume Next
For Counter = 1 To 9
Application.ActivePrinter = _
"\\mynetworkregion\myprinter on Ne0" & Counter
If Err.Number = 0 Then Exit For
Next
If Err.Number < 0 Then MsgBox "No print"
End Sub


--
Jim
"Janis" wrote in message
...
|I don't know how to make this error handler loop through the possible
network
| numbers. The current network number is 02 for the printer but it can
change
| from 01 through 09. If they change it I would like it to loop through the
| possibilities and then if it can't print give the user a warning.
|
| Dim NetworkNumb as string
| NetworkNumb = Ne02:
|
| On Error GoTo errGetFile
| ' the network number can change, if error try another number
| between 1 through 9
| Application.ActivePrinter = "\\mynetworkregion\myprinter on " &
NetworkNumb
| Exit Sub
| ' handle possible printer exceptions
| errGetFile
| Application.ActivePrinter = "\\mynetworkregion\myprinter on
| Ne01:"
|
| Else
| MsgBox " warning there is a problem with the printstring."
| Resume Next
|
|
| tia,





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
Infinite Loop in Error Handler chris Excel Discussion (Misc queries) 2 September 18th 07 02:10 AM
members on my network printer not able to print to default printer smeheut Excel Discussion (Misc queries) 0 June 18th 07 06:42 PM
Selecting a Printer on a network Dave Peterson Excel Programming 1 January 24th 07 08:23 PM
selecting network printer Bill Kuunders Excel Programming 0 January 11th 05 08:22 PM
Error handler loop? zSplash Excel Programming 4 October 10th 03 11:00 PM


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

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

About Us

"It's about Microsoft Excel"