View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default xlSheetVeryHidden vs xlSheetVisible

with the caution that Entrance can not be the last sheet.

--
Regards,
Tom Ogilvy


"Die_Another_Day" wrote:

Not sure if this helps any but I can significantly shorten the code for
you.

Private Sub Workbook_Open()
' Make all sheets very hidden except Entrance sheet
Dim ws As Worksheet
Application.EnableEvents = False
ThisWorkbook.Unprotect (PWORD_Workbook)

For Each ws in ThisWorkbook.Sheets
If ws.Name < "Entrance" Then
ws.Visible = -2 'VeryHidden, 0 For Hidden
Else
ws.Visible = -1 'Visible
End If
Next
Worksheets("Entrance").Activate

ThisWorkbook.Protect (PWORD_Workbook)
Application.EnableEvents = True

End Sub

Charles Chickering

Steve E wrote:
Been scratching my head for a few hours and am ready to call in the "A" team...

My project was opening fine and having no problems. I changed a macro
assignment on a button and now am getting an error when I open the project:

"Unable to set the Visible property of the Worksheet class"

My XL2003 project consists of a workbook with 9 worksheets.
I have (had?) the project set up so that when the workbook opens there is an
"entrance" sheet that explains to my user how to use the program. All of the
other sheets are hidden. My user clicks on a button and this opens up the
quote form...

But now my project is opening with the error and the sheet that is open is
the quote form...

When I go to the workbook module (where I am setting the visible sheets, etc
in my Workbook_Open event and try and run this sub I get this error message:

"Application defined or Object defined error"

But I can't find what I've gotten goofed up...

In a seperate module I have:

Public Const PWORD_Workbook As String = "password"


And in my ThisWorkbook module I have:

Private Sub Workbook_Open()
'
' Make all sheets very hidden except Entrance sheet

Application.EnableEvents = False
ThisWorkbook.Unprotect (PWORD_Workbook)

ThisWorkbook.Sheets("Fabric Colors").Visible = xlSheetVeryHidden
ThisWorkbook.Sheets("Input Lists").Visible = xlSheetVeryHidden
ThisWorkbook.Sheets("Quote Form").Visible = xlSheetVeryHidden
ThisWorkbook.Sheets("Bill of Materials").Visible = xlSheetVeryHidden
ThisWorkbook.Sheets("Margin Structure").Visible = xlSheetVeryHidden
ThisWorkbook.Sheets("Shipping Costs").Visible = xlSheetVeryHidden
ThisWorkbook.Sheets("zips").Visible = xlSheetVeryHidden
ThisWorkbook.Sheets("Dealer List").Visible = xlSheetVeryHidden
' Make Entrance Sheet visible and active
ThisWorkbook.Sheets("Entrance").Visible = xlSheetVisible
Worksheets("Entrance").Activate

ThisWorkbook.Protect (PWORD_Workbook)
Application.EnableEvents = True

End Sub

Can you see what I have goofed up and help me ungoof it?

TIA,

Steve