Once I used this for that purpose.
It is a double check. First you have to open Sheet Properties and Show it conditionally to these 2 variables: Contraseña (Password) and Pase (Pass). Also, it is convenient to hide tabs. Using this method, the sheet will not appear in the tool bar Sheets. I´m sure they are other ways. For example by user.
PassBox = InputBox("Por favor, escriba la contraseña", "Contraseña")
set w = ActiveDocument.Variables("contrasena")
set v = ActiveDocument.Variables("pase")
if PassBox = w.GetContent.String then
v.SetContent "si" , true
MsgBox "Contraseña Incorrecta", , "Contraseña"
If you don't need additional security, and you only want to show/hide a sheet (instead of an object) using only one button, do the following:
- Create a variable vSheetVisible (Settings menu, Variable Overview) and set it to 1
- then create the button, and in the properties, General tab, set its text to
=If(vSheetVisible = 1, 'Hide Sheet', 'Show Sheet')
- In the button's properties, go to Actions tab, add External, Set Variable vSheetVisible and value
=If(vSheetVisible = 1, 0, 1)
- Now go to the sheet you want to show/hide and click on the background, properties, General tab, Show Sheet, Conditional and set the following condition
vSheetVisible = 1
And that's all.
Hope that helps.