Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Passwords in macros | Excel Worksheet Functions | |||
Passwords | Excel Discussion (Misc queries) | |||
2 separate passwords (both valid) to open file | Excel Discussion (Misc queries) | |||
Random Passwords | Excel Worksheet Functions | |||
HELP!? Passwords are driving me crazy. | Excel Worksheet Functions |