printer exception, error handler, need to loop through network num

J

Janis

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,
 
J

Jim Rech

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
|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,
 
J

Jim Rech

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
|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
| ||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,
|
|
 
J

Janis

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.
 
J

Janis

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top