Hide sheets and allow form

  • Thread starter Thread starter Alain R.
  • Start date Start date
A

Alain R.

Hi,

When my user open the XLS file, i would like to be sure that all sheets
are hidden and that a particular form is displayed.
this form should be somehow modal to be sure that user can not click on
Excel application menu or somewhere else.

how can i do that ?

thx.

A.
 
first off you'll need at least one visible sheet
next, make all the other sheets xlhidden or xlveryhidden

Sub HideSheets()
dim ws as worksheet
for each ws in worksheets
if ws.name <> "Sheet1" then
ws.Visible = xlveryhidden
end if
next
End Sub

show the userform from the workbook's open event
to do this, go to the development environment (ALT+F11), then in the project
view right click on ThisWorkbook and select View Code
In the code sheet, select Workbook from the object dropdown - you'll see
<General> by default
- and you'llprobably get the Open methods SUB/END SUB stubs entered by
default
add the show userform code as per this example:

Private Sub Workbook_Open()
UserForm1.Show
End Sub
 
Back
Top