Problem with code to print - out of order

S

Steph

Hi everyone. I have some code that references column D, which has the full
path of a file, and column A which has a checkbox. The code
opens every file (one at a time) that is listed in column D with a check in
A, updates links, prints the sheets listed in columns E through BB, and then
finally closes the file. It then loops through all files listed.

I noticed that when this runs, the sheets come in in a somewhat jumbled
order. Is it possible that the code is processing too quickly, and when the
jobs get spooled to the printer they sometimes jump out of order? Would a
pause between print commands help? I really need the files and sheets to
come out in the exact order that they are listed in the worksheet. Thanks
for your help!



Sub PrintFiles()

Dim rng As Range, rng1 As Range
Dim cell As Range, cell1 As Range
Dim bk As Workbook
Dim WbOpen As String
Dim mysheet As Worksheet

Application.DisplayAlerts = False
Application.ScreenUpdating = False


Set rng = Range("D7:D" & Range("D65536").End(xlUp).Row)
For Each cell In rng
If Trim(cell.Value) <> "" Then
If Cells(cell.Row, 1).Value = True Then
WbOpen = cell.Value
Workbooks.Open (WbOpen), UpdateLinks:=1
Set bk = ActiveWorkbook

ThisWorkbook.Activate
Set rng1 = cell.Offset(0, 1).Resize(1,
50).SpecialCells(xlConstants)
For Each cell1 In rng1
If LCase(cell1.Value) = "all" Then
bk.PrintOut
'Cells(cell.Row, 4).Interior.ColorIndex = 35
Exit For
Else
If Trim(cell1.Value) <> "" Then
bk.Worksheets(cell1.Value).PrintOut
End If
End If
Next

WbOpen = ""
bk.Close SaveChanges:=True
Set bk = Nothing
End If
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = False

End Sub
 

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