Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Hide sheets when book is opened

I have a work book with a main page that I would like to be the only page the
user sees when they open the book. This page has command buttons to jump to
the other seven pages. I would like to add some code to the buttons to unhide
the pages and then jump to that page.

Could anyone help with this please.

Thanks in advance for any responses.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Hide sheets when book is opened

I don't believe that you can hide sheets. You can hide a workbook. I am no
expert, but I would suggest using 8 different workbooks (1 for the "Main"
page, and 7 one Sheet workbooks). Double click your ThisWorkbook object in
your Project explorer
Private Sub Workbook_Open()

Application.DisplayAlerts = False 'if individual workbooks contain there own
macros
Workbooks.Open Filename:="C:/FirstBook.xls"
Workbooks.Open Filename:="C:/SecondBook.xls"
etc...
End Sub

the sheets that are now the individual workbook should have the following
code in the ThisWorkbook Object:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error Resume Next 'it may already be visible
Windows("FirstBook.xls").Visible = False
End Sub

Your CommandButtons should unhide the workbook.
Sub CommandButton1_Click()
Windows("FirstBook.xls").Visible = True
end sub

I'm sure that someone will give you a better solution, but It's the best I
can do. Good luck.



"Mark Dullingham" wrote:

I have a work book with a main page that I would like to be the only page the
user sees when they open the book. This page has command buttons to jump to
the other seven pages. I would like to add some code to the buttons to unhide
the pages and then jump to that page.

Could anyone help with this please.

Thanks in advance for any responses.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Hide sheets when book is opened

Mark, this should get you started,

Put this in the thisworkbok code, will hide all sheets except sheet1 when
you open the workbook, if macros are enabled

Private Sub Workbook_Open()
Dim sh As Worksheet
For Each sh In Worksheets
If Not sh.Name = "Sheet1" Then
sh.Visible = xlSheetVeryHidden
End If
Next sh
End Sub

Then use something like this for your buttons

Sub GoTo_Sheet2()
Sheets("Sheet2").Visible = True
Sheets("Sheet2").Select

End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Mark Dullingham" wrote in
message ...
I have a work book with a main page that I would like to be the only page

the
user sees when they open the book. This page has command buttons to jump

to
the other seven pages. I would like to add some code to the buttons to

unhide
the pages and then jump to that page.

Could anyone help with this please.

Thanks in advance for any responses.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Hide sheets when book is opened

Hi Paul

Thanks for your help the work book code worked a treat, Just what I was
looking for.
The code for the button ended up like this

Private Sub CommandButton1_Click()
Sheets("Sheet 1").Visible = True
Sheets("Sheet 1").Select
End Sub

Once again thanks for your help

Mark

"Paul B" wrote:

Mark, this should get you started,

Put this in the thisworkbok code, will hide all sheets except sheet1 when
you open the workbook, if macros are enabled

Private Sub Workbook_Open()
Dim sh As Worksheet
For Each sh In Worksheets
If Not sh.Name = "Sheet1" Then
sh.Visible = xlSheetVeryHidden
End If
Next sh
End Sub

Then use something like this for your buttons

Sub GoTo_Sheet2()
Sheets("Sheet2").Visible = True
Sheets("Sheet2").Select

End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Mark Dullingham" wrote in
message ...
I have a work book with a main page that I would like to be the only page

the
user sees when they open the book. This page has command buttons to jump

to
the other seven pages. I would like to add some code to the buttons to

unhide
the pages and then jump to that page.

Could anyone help with this please.

Thanks in advance for any responses.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Hide sheets when book is opened

Glad it worked out for you

--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Mark Dullingham" wrote in
message ...
Hi Paul

Thanks for your help the work book code worked a treat, Just what I was
looking for.
The code for the button ended up like this

Private Sub CommandButton1_Click()
Sheets("Sheet 1").Visible = True
Sheets("Sheet 1").Select
End Sub

Once again thanks for your help

Mark

"Paul B" wrote:

Mark, this should get you started,

Put this in the thisworkbok code, will hide all sheets except sheet1

when
you open the workbook, if macros are enabled

Private Sub Workbook_Open()
Dim sh As Worksheet
For Each sh In Worksheets
If Not sh.Name = "Sheet1" Then
sh.Visible = xlSheetVeryHidden
End If
Next sh
End Sub

Then use something like this for your buttons

Sub GoTo_Sheet2()
Sheets("Sheet2").Visible = True
Sheets("Sheet2").Select

End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Mark Dullingham" wrote in
message ...
I have a work book with a main page that I would like to be the only

page
the
user sees when they open the book. This page has command buttons to

jump
to
the other seven pages. I would like to add some code to the buttons to

unhide
the pages and then jump to that page.

Could anyone help with this please.

Thanks in advance for any responses.






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
EXCEL WORK BOOK DUPLICATES WHEN OPENED Asoka Walpitagama - Brandix College IT Excel Discussion (Misc queries) 1 November 18th 09 02:25 PM
Auto sort when worksheet/book opened Lise Excel Discussion (Misc queries) 4 October 26th 08 12:35 AM
Create New Workbook - Name book - 4 Sheets - Name Sheets Greg[_21_] Excel Programming 6 June 12th 05 04:41 AM
Strange error if another Excel book is opened Paul Excel Programming 1 March 15th 05 03:35 PM
how to make a macro and run in every excel book that opened? wayan Excel Programming 3 February 22nd 05 08:47 AM


All times are GMT +1. The time now is 05:48 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"