Hide sheets and allow form

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.
 
P

Patrick Molloy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top