View Full Version : VBA does not print

09-02-2016, 07:20 AM
Hi good people!,

I have posted this on Mr Excel, this is the link: http://www.mrexcel.com/forum/excel-questions/962394-printout-problem.html

I have not received any response so I'm trying here. Please help with this code, All works fine except the printing part. ".Printout" is yellow and the error is "Printout method of worksheet class failed".

This is the code:
Sub PrintPlannedJobs()
' PrintPlannedJobs Macro
Application.ScreenUpdating = False
Sheets("work order 1").Visible = True
Sheets("work order 1").Activate
MsgBox (Sheets("Scheduler").Range("AB2").Value & " Records Found")
If vbOK Then
If Sheets("Scheduler").Range("AB2").Value = 0 Then
Exit Sub


If Sheets("Scheduler").Range("AB2").Value <> 0 Then
Dim Answer As Integer
Answer = MsgBox("Would You Like To Print These " & Range("AB2") & " Work Orders?", vbOKCancel)
End If

If Answer = vbOK Then

Dim sht
Application.ScreenUpdating = False
For Each sht In Sheets
If sht.Visible And sht.Name <> "SCHEDULER" Then
With sht
End With
End If
Application.EnableEvents = False
End If
Exit Sub

Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
If WS.Name <> ActiveSheet.Name Then WS.Visible = xlSheetVeryHidden
Next WS

End If
End If
End Sub

all and any help will be very much appreciated!!..thank you all!!