Printing Hidden Worksheets

  • Thread starter Thread starter jkyndt
  • Start date Start date
J

jkyndt

Hi,

I have hidden 4 worksheets and have created a macro which prints th
whole workbook. Unfortunately the macro (attached to a button) will no
print the hidden sheets.

I can't seem to find the solution. Do any of you have a tip?

Cheers

Jame
 
You must unhide the sheets

This will print all hidden sheets

Sub test()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.Visible = False Then
sh.Visible = True
sh.PrintOut
sh.Visible = False
End If
Next
End Sub
 
Hi James

I add a example to my print page
http://www.rondebruin.nl/print.htm

Sub Print_Hidden_Worksheets()
'xlSheetVisible = -1
'xlSheetHidden = 0
'xlSheetVeryHidden = 2
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
If sh.Visible = 0 Or sh.Visible = 2 Then

If sh.Visible = 0 Then
sh.Visible = -1
sh.PrintOut
sh.Visible = 0
End If

If sh.Visible = 2 Then
sh.Visible = -1
sh.PrintOut
sh.Visible = 2
End If
End If
Next
End Sub
 
Maybe just get the current state, make it visible (no harm if it's already
visible), print it, and then change it back (no harm if there's no change):

Option Explicit
Sub Print_Hidden_Worksheets()
Dim curVis As Long
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
With sh
curVis = .Visible
.Visible = xlSheetVisible
.PrintOut 'preview:=True 'for testing
.Visible = curVis
End With
Next sh
End Sub
 
Nice one to print all sheets (hidden and visible) in the workbook Dave
I add it to the page if you don't mind.

If you do i delete it<g>
 
It's yours now!


Ron de Bruin said:
Nice one to print all sheets (hidden and visible) in the workbook Dave
I add it to the page if you don't mind.

If you do i delete it<g>
<<snipped>>
 

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

Back
Top