Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro works correctly on my PC but not on others

Status
Not open for further replies.

renigar

Technical User
Jan 25, 2002
111
US
I have a simple Excel macro that prints out vehicle inspection sheets. This is a chore that is done monthly at work. The macro prints sheets based on what vehicles are in a list. The sheets are named for each vehicle number and the list the macro refers to are the vehicle numbers to be printed. It will print all the vehicles in the list from my computer but for some others users it will print the first two vehicle sheets and end. I have experienced this with other similar type macros here at work and have been meaning to ask if anyone knows what's going on for some time. The excel file is stored on the network and all printing is done to network printers. Most users here have Office 365. If I step through the macro on one of the computers that it fails on it works without incident. It makes me think there might a timing issue. The code follows.

Code:
Sub VehicleForms()
' Print Vehicle Inspection forms

Dim lastrow As Long
Dim shtName As String
Dim i As Long

' Activate the worksheet with the vehicle list in column M
Worksheets("Set Date").Activate

' Get the number of the last row
lastrow = Cells(Rows.Count, 13).End(xlUp).Row 'The 13 is column M

' This line is in case someone leaves a blank cell in the list
' the code will skip to the next row
On Error Resume Next
' Loop through the list in column M printing each sheet
   For i = 2 To lastrow
     shtName = Cells(i, 13)
     Sheets(shtName).PrintOut Copies:=1
   Next

End Sub
 
Did you try to delay the execution of
[tt]Sheets(shtName).PrintOut Copies:=1[/tt]
for a couple of seconds and see if that will help [ponder]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Andrzejek,

I added a two second delay and that did the trick. I still don't understand why. It always works if I print from my computer. All the computers in my office are on the same network. It may be that some users are on thin clients (I hate those). Those things are always slower. At least I got a fix.

Thanks,
renigar
 
Maybe in MS Office options on your pc background printing is turned off.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top