Passwords

  • Thread starter Thread starter K1KKKA
  • Start date Start date
K

K1KKKA

Hi, i have created a userform to ask for a password when a macro button
is pressed, i would like them to enter the password before the macro
runs,

Any help with the code for this?
 
Ignore the above, have managed the code and works fine :)

But another question?

I have a macro that runs upon opening the workbook, is there a code i
could use that if the macros are disabled, then all sheets are hidden,
or the workbook will save/close if the disable option is chosen?


Steve
 
or How about keeping the sheets hidden as default. and if macro is enabled,
then the macro makes the sheets visible ?
 
The standard way to approach this is as follows.
- create a worksheet with a message on explaining that for this workbook to
run it needs macros enabled, maybe even a few screenshots
- hide all other worksheets
- add some code in the Workbook_Open event that un hides the other sheets,
but hides that sheet.

What happens is that if they do not enable macros, they will only see the
warning sheet, telling them how to do it. If they enable macros,it will
startup the workbook as it should be.


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 
Bob,

Thanks for the reply, understand this option, but have tried a code i
thought would work for this, but not much luck, any idea what it should
look like?

Many thanks
Steve
 
This would be what the code looks like. As I said, create a warning
worksheet with details of what has happened on it, and then add this code

Option Explicit

Private Const shWarn As String = "Warning"

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim sh As Sheet1
Worksheets(shWarn).Visible = True
For Each sh In ThisWorkbook.Sheets
If sh.Name <> shWarn Then sh.Visible = False
Next sh
End Sub

Private Sub Workbook_Open()
Dim sh As Sheet1
For Each sh In ThisWorkbook.Sheets
sh.Visible = True
Next sh
Worksheets(shWarn).Visible = False
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 
So would I. Thanks Jim <g>

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 

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

Similar Threads

Buttons in excel 2003 3
How to get a file from a web page 1
Windows 10 W10 password prob. 2
Password on Macro Button 3
Action after save 3
Macro to create Sort buttons 8
2003 Macro in Excel 2007 1
Passwords 2

Back
Top