I set up a macro a couple of years ago. We have to print out acct forms once per year and mail them out. This has worked fine for a couple of years. Now this year (not changing any code) it prints the first one and then gets hung up until excel completely crashes.
If I step through the code. it works just fine. Only problen is there are 2400 of these and for me to step through all 2400 is kinda a waste of time. (Just sitting holding down the "F8" key) We do have a new network printer (Copy Machine). So I am wondering if it's the printer? Do I need a pause someplace in the code. Any thoughts?
Here is the code that was working and now doesn't. It's hard to know where the problem is. If I step through the code it works fine. It's when I just release and let it run. It shows the print box, counts up the pages from 1 to 4 then just freezes. Stays that way for about 2 mins then shuts down Excel.
PrtPg5 = True
Sheets("Form").Activate
StartRow = Range("StartRow")
EndRow = Range("EndRow")
If StartRow > EndRow Then
Msg = "ERROR" & vbCrLf & "The starting row must be less than the ending row!"
MsgBox Msg, vbCritical, APPNAME
End If
For i = StartRow To EndRow
Range("RowIndex") = i
'For Footer
acct = Worksheets("Form").Range("A308").Value
Worksheets("Form").PageSetup.CenterFooter = "&""OCR A Extended,Regular""&12" & acct
'Checks if need page 5 printed
If XI > 0 Or XX > 0 Or XH > 0 Then
PrtPg5 = True
ActiveSheet.PageSetup.PrintArea = "Print5"
Else
PrtPg5 = False
ActiveSheet.PageSetup.PrintArea = "Print4"
End If
If Range("Preview") Then
ActiveSheet.PrintPreview
Else
ActiveSheet.PrintOut
Application.ScreenUpdating = True
End If
Next i
TIA
If I step through the code. it works just fine. Only problen is there are 2400 of these and for me to step through all 2400 is kinda a waste of time. (Just sitting holding down the "F8" key) We do have a new network printer (Copy Machine). So I am wondering if it's the printer? Do I need a pause someplace in the code. Any thoughts?
Here is the code that was working and now doesn't. It's hard to know where the problem is. If I step through the code it works fine. It's when I just release and let it run. It shows the print box, counts up the pages from 1 to 4 then just freezes. Stays that way for about 2 mins then shuts down Excel.
PrtPg5 = True
Sheets("Form").Activate
StartRow = Range("StartRow")
EndRow = Range("EndRow")
If StartRow > EndRow Then
Msg = "ERROR" & vbCrLf & "The starting row must be less than the ending row!"
MsgBox Msg, vbCritical, APPNAME
End If
For i = StartRow To EndRow
Range("RowIndex") = i
'For Footer
acct = Worksheets("Form").Range("A308").Value
Worksheets("Form").PageSetup.CenterFooter = "&""OCR A Extended,Regular""&12" & acct
'Checks if need page 5 printed
If XI > 0 Or XX > 0 Or XH > 0 Then
PrtPg5 = True
ActiveSheet.PageSetup.PrintArea = "Print5"
Else
PrtPg5 = False
ActiveSheet.PageSetup.PrintArea = "Print4"
End If
If Range("Preview") Then
ActiveSheet.PrintPreview
Else
ActiveSheet.PrintOut
Application.ScreenUpdating = True
End If
Next i
TIA