Printing Hidden Worksheets

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
 
R

Ron de Bruin

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
 
R

Ron de Bruin

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
 
D

Dave Peterson

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
 
R

Ron de Bruin

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>
 
D

Dave Peterson

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>>
 
Top