• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Printing entire workbook

I want to click a button and then print page one of each tab. But some tabs have more than one page (I can see this in page break preview).

Is this possible?
 
Hi DV

This should get your over the line. It worked in my office.

Code:
Sub test1()
Dim sh As Worksheet
 
    For Each sh In Sheets
        sh.PrintOut 1, 1, 1, , , , True, , False
    Next sh
End Sub

Take care

Smallman
 
Hi DV

This should get your over the line. It worked in my office.

Code:
Sub test1()
Dim sh As Worksheet

    For Each sh In Sheets
        sh.PrintOut 1, 1, 1, , , , True, , False
    Next sh
End Sub

Take care

Smallman

I did Alt + F11 and pasted this code into the 'Worksheet' module and saved. Then I went to print and I got more than just the first page.

I must have done something wrong.
 
@DashboardNovice

Place This Code in the Command Button and press

Code:
Private Sub CommandButton1_Click()
  Sheet1.PrintPreview True
   
  For i = 1 To Worksheets.Count
  strRes = MsgBox("Do you want to print " & Worksheets.Item(i).Name, vbOKCancel, "Print Preview")
  If strRes = 1 Then
  Worksheets.Item(i).PrintPreview True
  End If
  Next
   
End Sub

Hope it's solve other wise please inform

Thanks
 
Hi @DashboardNovice

Here is a simple test you can perform. Throw the code into a blank workbook put some random text on each sheet on Page 1, Page2 and any other page. Now print with the code i provided. You will notice that only sheet 1 of each sheet prints out.

Here is just that file. The code runs through perfectly. So you need to ask what is different between the test environment and your file.

Take care

Smallman
 

Attachments

  • BasicPrintTest.xls
    35 KB · Views: 3
Back
Top