#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Passwords

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?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Passwords

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default Passwords

or How about keeping the sheets hidden as default. and if macro is enabled,
then the macro makes the sheets visible ?


"K1KKKA" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,726
Default Passwords

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)


"K1KKKA" wrote in message
ps.com...
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



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default Passwords

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


Bob Phillips wrote:

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)


"K1KKKA" wrote in message
ps.com...
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




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,726
Default Passwords

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)


"K1KKKA" wrote in message
ups.com...
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


Bob Phillips wrote:

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)


"K1KKKA" wrote in message
ps.com...
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




  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Passwords

The only thing I might add would be instead of using

If sh.Name < shWarn Then sh.Visible = False

I would be inclined to use
If sh.Name < shWarn Then sh.Visible = xlSheetVeryHidden

Which will make the sheets very hidden meaning that the user could not go to
Format - Sheet - Unhide and make the sheets visible. The only way to make
the sheets visible is through code...
--
HTH...

Jim Thomlinson


"Bob Phillips" wrote:

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)


"K1KKKA" wrote in message
ups.com...
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


Bob Phillips wrote:

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)


"K1KKKA" wrote in message
ps.com...
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





  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,726
Default Passwords

So would I. Thanks Jim <g

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Jim Thomlinson" wrote in message
...
The only thing I might add would be instead of using

If sh.Name < shWarn Then sh.Visible = False

I would be inclined to use
If sh.Name < shWarn Then sh.Visible = xlSheetVeryHidden

Which will make the sheets very hidden meaning that the user could not go
to
Format - Sheet - Unhide and make the sheets visible. The only way to
make
the sheets visible is through code...
--
HTH...

Jim Thomlinson


"Bob Phillips" wrote:

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)


"K1KKKA" wrote in message
ups.com...
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


Bob Phillips wrote:

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)


"K1KKKA" wrote in message
ps.com...
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







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passwords in macros Julian Glass Excel Worksheet Functions 1 October 24th 06 03:28 PM
Passwords Cathi Excel Discussion (Misc queries) 1 October 13th 06 06:01 PM
2 separate passwords (both valid) to open file regi Excel Discussion (Misc queries) 3 October 2nd 06 04:55 PM
Random Passwords RUSS Excel Worksheet Functions 4 February 14th 06 12:01 AM
HELP!? Passwords are driving me crazy. NoviceJESS Excel Worksheet Functions 6 January 21st 05 06:02 AM


All times are GMT +1. The time now is 05:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"