J
Janis
I have this sub called in another routine which does the page setup and sets
the page breaks and formatting for the user to print. I took out the code
below called setprinter and made it into a subroutine because it is called
in other scripts. The loop doesn't seem to be working.
I tried to debug it and this is what happens: It goes through the first
loop and sets counter to 1. Then it gets a 0 error and passes 0 to the
counter variable outside this script or else it is already 0 and nothing
happens because I didn't pass it out of this subroutine.
The network number changes becuase it is not fixed but dynamic so I want it
to loop through and get the right number. The loop should have found an error
and gone and tried network 2.
Question 1: why doesn't it find the error and try the 2nd iteration?
Question 2: how do I pass it to the main script?
tia,
Public Sub setPrinter()
Dim Counter As Integer
' This function loops through the number 1-9 because the _
network on the printer is not stationary _
but changes from Network 1 - 9.
On Error Resume Next
For Counter = 1 To 9
Err.Clear
Application.ActivePrinter = "\\martinezfs1-bay\Ca-Martinez-94C on Ne0" &
Counter & ":"
If Err.Number = 0 Then Exit For
MsgBox "Network Printer" & Counter
Next
If Err.Number <> 0 Then MsgBox "the command to print has an error."
MsgBox Err.Number
End Sub
the page breaks and formatting for the user to print. I took out the code
below called setprinter and made it into a subroutine because it is called
in other scripts. The loop doesn't seem to be working.
I tried to debug it and this is what happens: It goes through the first
loop and sets counter to 1. Then it gets a 0 error and passes 0 to the
counter variable outside this script or else it is already 0 and nothing
happens because I didn't pass it out of this subroutine.
The network number changes becuase it is not fixed but dynamic so I want it
to loop through and get the right number. The loop should have found an error
and gone and tried network 2.
Question 1: why doesn't it find the error and try the 2nd iteration?
Question 2: how do I pass it to the main script?
tia,
Public Sub setPrinter()
Dim Counter As Integer
' This function loops through the number 1-9 because the _
network on the printer is not stationary _
but changes from Network 1 - 9.
On Error Resume Next
For Counter = 1 To 9
Err.Clear
Application.ActivePrinter = "\\martinezfs1-bay\Ca-Martinez-94C on Ne0" &
Counter & ":"
If Err.Number = 0 Then Exit For
MsgBox "Network Printer" & Counter
Next
If Err.Number <> 0 Then MsgBox "the command to print has an error."
MsgBox Err.Number
End Sub