Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Hide / Unhide Workshets on Print and Open

I have two worksheets in a file that I'd like to unhide when the file is
opened and I'd like to hide them prior to printing since they should not be
printed when "print entire workbook" is chosen. They are named VAV Data and
FPB Data. They may or may not be hidden when the file is closed.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Hide / Unhide Workshets on Print and Open

Try this on the Thisworkbook code module:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True

'hide the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible

With Application
.EnableEvents = False
.Dialogs(xlDialogPrint).Show
.EnableEvents = True
End With

'show the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible
End Sub

Private Sub Workbook_Open()
'show the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible
End Sub

--
Hope that helps.

Vergel Adriano


"Mr. Matt" wrote:

I have two worksheets in a file that I'd like to unhide when the file is
opened and I'd like to hide them prior to printing since they should not be
printed when "print entire workbook" is chosen. They are named VAV Data and
FPB Data. They may or may not be hidden when the file is closed.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Hide / Unhide Workshets on Print and Open

Correction.

This part of the code:

'hide the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible

should be like this:

'hide the sheets
Sheets("VAV Data").Visible = xlSheetHidden
Sheets("FPB Data").Visible = xlSheetHidden


--
Hope that helps.

Vergel Adriano


"Vergel Adriano" wrote:

Try this on the Thisworkbook code module:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True

'hide the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible

With Application
.EnableEvents = False
.Dialogs(xlDialogPrint).Show
.EnableEvents = True
End With

'show the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible
End Sub

Private Sub Workbook_Open()
'show the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible
End Sub

--
Hope that helps.

Vergel Adriano


"Mr. Matt" wrote:

I have two worksheets in a file that I'd like to unhide when the file is
opened and I'd like to hide them prior to printing since they should not be
printed when "print entire workbook" is chosen. They are named VAV Data and
FPB Data. They may or may not be hidden when the file is closed.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Hide / Unhide Workshets on Print and Open

Excellent. Thanks a lot.

Is there any way to print those sheets that I hide if I want to review the
data on them? I can disallow the macro when I open the file, but is there a
way to do it from within Excel?

Thanks

"Vergel Adriano" wrote:

Correction.

This part of the code:

'hide the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible

should be like this:

'hide the sheets
Sheets("VAV Data").Visible = xlSheetHidden
Sheets("FPB Data").Visible = xlSheetHidden


--
Hope that helps.

Vergel Adriano


"Vergel Adriano" wrote:

Try this on the Thisworkbook code module:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True

'hide the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible

With Application
.EnableEvents = False
.Dialogs(xlDialogPrint).Show
.EnableEvents = True
End With

'show the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible
End Sub

Private Sub Workbook_Open()
'show the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible
End Sub

--
Hope that helps.

Vergel Adriano


"Mr. Matt" wrote:

I have two worksheets in a file that I'd like to unhide when the file is
opened and I'd like to hide them prior to printing since they should not be
printed when "print entire workbook" is chosen. They are named VAV Data and
FPB Data. They may or may not be hidden when the file is closed.

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Hide / Unhide Workshets on Print and Open

You can use a macro like the one below. It turns off events then shows the
print dialog without hiding any of your data sheets..

Sub SpecialPrint()
With Application
.EnableEvents = False
.Dialogs(xlDialogPrint).Show
.EnableEvents = True
End With
End Sub


--
Hope that helps.

Vergel Adriano


"Mr. Matt" wrote:

Excellent. Thanks a lot.

Is there any way to print those sheets that I hide if I want to review the
data on them? I can disallow the macro when I open the file, but is there a
way to do it from within Excel?

Thanks

"Vergel Adriano" wrote:

Correction.

This part of the code:

'hide the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible

should be like this:

'hide the sheets
Sheets("VAV Data").Visible = xlSheetHidden
Sheets("FPB Data").Visible = xlSheetHidden


--
Hope that helps.

Vergel Adriano


"Vergel Adriano" wrote:

Try this on the Thisworkbook code module:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True

'hide the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible

With Application
.EnableEvents = False
.Dialogs(xlDialogPrint).Show
.EnableEvents = True
End With

'show the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible
End Sub

Private Sub Workbook_Open()
'show the sheets
Sheets("VAV Data").Visible = xlSheetVisible
Sheets("FPB Data").Visible = xlSheetVisible
End Sub

--
Hope that helps.

Vergel Adriano


"Mr. Matt" wrote:

I have two worksheets in a file that I'd like to unhide when the file is
opened and I'd like to hide them prior to printing since they should not be
printed when "print entire workbook" is chosen. They are named VAV Data and
FPB Data. They may or may not be hidden when the file is closed.

Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide/Unhide [email protected] Excel Discussion (Misc queries) 0 July 24th 08 05:02 PM
hide/unhide brownti Excel Discussion (Misc queries) 3 February 6th 07 07:14 PM
Macro to Paste Items to All but Several Workshets Magnivy Excel Programming 5 June 10th 06 08:24 PM
Hide Unhide Colin Excel Discussion (Misc queries) 4 April 9th 06 05:01 PM
Hide, Print, Unhide Rows pfosz Excel Programming 1 November 23rd 04 09:44 PM


All times are GMT +1. The time now is 02:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"