ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code for Printing Hidden Sheets (https://www.excelbanter.com/excel-programming/284265-code-printing-hidden-sheets.html)

Todd[_7_]

Code for Printing Hidden Sheets
 
Hi,

I have a project that includes one main sheet used to
collect necessary data and then a number of other sheets
that calculate and display the data in reports.

I would like to keep all of the report sheets hidden and
then be able to print from the main sheet by clicking a
command button relating to the sheet.

I've tried

Sub Print ()
Sheets("Report_To_Print").PrintOut Copies:=1,
Collate:=True
End Sub

However I get a compile error.

Is it possible to print a hidden sheet without making it
visible first? Can anybody offer a solution?

Thanks for your help,
Todd

Chip Pearson

Code for Printing Hidden Sheets
 
Todd,

You need to make the sheet visible first.

Application.ScreenUpdating = False
With Worksheets("Sheet1")
.Visible = xlSheetVisible
.PrintOut ' preview:=True
.Visible = xlSheetHidden
End With
Application.ScreenUpdating = True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Todd" wrote in message
...
Hi,

I have a project that includes one main sheet used to
collect necessary data and then a number of other sheets
that calculate and display the data in reports.

I would like to keep all of the report sheets hidden and
then be able to print from the main sheet by clicking a
command button relating to the sheet.

I've tried

Sub Print ()
Sheets("Report_To_Print").PrintOut Copies:=1,
Collate:=True
End Sub

However I get a compile error.

Is it possible to print a hidden sheet without making it
visible first? Can anybody offer a solution?

Thanks for your help,
Todd




Tom Ogilvy

Code for Printing Hidden Sheets
 
Sub Print ()
Dim lvis as Long
Application.ScreenUpdating = False
With Sheets("Report_To_Print")
lVis = .visible
.Visible = True
.PrintOut Copies:=1, Collate:=True
.visible = lVis
End With
Application.ScreenUpdating = True
End Sub

Is a possibility

--
Regards,
Tom Ogilvy


"Todd" wrote in message
...
Hi,

I have a project that includes one main sheet used to
collect necessary data and then a number of other sheets
that calculate and display the data in reports.

I would like to keep all of the report sheets hidden and
then be able to print from the main sheet by clicking a
command button relating to the sheet.

I've tried

Sub Print ()
Sheets("Report_To_Print").PrintOut Copies:=1,
Collate:=True
End Sub

However I get a compile error.

Is it possible to print a hidden sheet without making it
visible first? Can anybody offer a solution?

Thanks for your help,
Todd





All times are GMT +1. The time now is 07:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com