PrintOut Error

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,616
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Would someone be able to guide me to a solution to defeat the " Printout method of Worksheet class failed." error I'm getting in the highlighted line of code below?

Rich (BB code):
Sub printme_d()
    Dim rwtopLeft As Long, coltopLeft As Long
    Dim rwbtmRight As Long, colbtmRight As Long
    Dim diarng As Range
    'Stop
    
    rwtopLeft = Application.WorksheetFunction.VLookup("D", ws_lists.Range("X3:AD10"), 3, False)
    coltopLeft = Application.WorksheetFunction.VLookup("D", ws_lists.Range("X3:AD10"), 4, False)
    rwbtmRight = Application.WorksheetFunction.VLookup("D", ws_lists.Range("X3:AD10"), 5, False) + 43
    colbtmRight = Application.WorksheetFunction.VLookup("D", ws_lists.Range("X3:AD10"), 6, False) + 55
'Stop
    Set diarng = ws_front.Range(ws_front.Cells(rwtopLeft, coltopLeft), ws_front.Cells(rwbtmRight, colbtmRight))
    
    With ws_front.PageSetup
        ws_front.Unprotect
        .PrintArea = "J" & rwtopLeft & ":BM" & rwbtmRight
        pgnums = .Pages.Count
        ws_front.Protect
    End With
    
    ui1 = InputBox("Select:" & Chr(13) & "    (1)   SAVE Only" & _
        Chr(13) & "    (2)   PRINT Only" & _
        Chr(13) & "    (3)   PRINT & SAVE", "Output Selection")
        
    If ui1 = "1" Then
        savemed
        
    ElseIf ui1 = "2" Then
        Stop
        ws_front.PrintOut
        ui1 = MsgBox("Pages printed: " & pgnums & Chr(13) & "Retrieve printed pages and return to printer tray, face down, top into machine." & Chr(13) & _
            "Press OK to launch print the reverse side of the signature sheets.", vbQuestion + vbOKCancel, "PRINT COMMAND")
        If ui1 = vbOK Then
            With Worksheets("Dia_Backside").PageSetup
                Worksheets("Dia_Backside").Unprotect
                .PrintArea = "A1:BD45"
                Worksheets("Dia_Backside").Protect
            End With
            ws_front.Protect
            For pg = 1 To pgnums
                Worksheets("Dia_Backside").PrintOut
            Next pg
        End If
        
    Else
        ws_front.PrintOut
        ui1 = MsgBox("Pages printed: " & pgnums & Chr(13) & Chr(13) & "Retrieve printed pages and return to printer tray, face down, top into machine." & Chr(13) & Chr(13) & _
            "Press OK to launch print the reverse side of the signature sheets.", vbQuestion + vbOKCancel, "PRINTING: Diamonds")
        If ui1 = vbOK Then
            With Worksheets("Dia_Backside").PageSetup
                Worksheets("Dia_Backside").Unprotect
                .PrintArea = "A1:BD45"
                Worksheets("Dia_Backside").Protect
            End With
            ws_front.Protect
            For pg = 1 To pgnums
                Worksheets("Dia_Backside").PrintOut
            Next pg
        End If
        savemed
    End If
    
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top