Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All,
I need some help in programming my workbook to not open if the user tries to open with macros disabled. As you know, the user can set the security level to "high", "medium", or "low". I would like my workbook to be able to react in the cases where the level is set to "high" or "medium" because in these respectively, any macro will be automatically disabled or the user prompted to opt to either enable or disable all macros. So, should the system automatically disable macros or the user ultimately decide to disable macros when prompted, I need my workbook to react by quickly closing (or not opening at all). My idea was to check what security level is in place: if set to "high" then force the workbook to immediately close again; but if set to "medium" then to capture the user's response event when the system prompts the user, and close the workbook if the choice was to disable macros. Having taken 20mins to write the above succinctly, it has now occured to me that if the system or user disables macros then my code to close the workbook won't work anyway (!!)....or will it. I guess I'm looking for any ideas - or confirmation that it simply can't be done :[ Thanks and appreciation if you're still with me! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's what I do....
Write code that does this: Upon close....Hide all sheets: xlVeryHidden except one. Upon Open...Unhide all sheets. That way, if macros are disabled...all they see is the one sheet with a message telling them that they need to enable macros to see the rest of the workbook. It's not bullet-proof....but, it's pretty good. :) Does that help? *********** Regards, Ron XL2002, WinXP-Pro "I Believe" wrote: Hi All, I need some help in programming my workbook to not open if the user tries to open with macros disabled. As you know, the user can set the security level to "high", "medium", or "low". I would like my workbook to be able to react in the cases where the level is set to "high" or "medium" because in these respectively, any macro will be automatically disabled or the user prompted to opt to either enable or disable all macros. So, should the system automatically disable macros or the user ultimately decide to disable macros when prompted, I need my workbook to react by quickly closing (or not opening at all). My idea was to check what security level is in place: if set to "high" then force the workbook to immediately close again; but if set to "medium" then to capture the user's response event when the system prompts the user, and close the workbook if the choice was to disable macros. Having taken 20mins to write the above succinctly, it has now occured to me that if the system or user disables macros then my code to close the workbook won't work anyway (!!)....or will it. I guess I'm looking for any ideas - or confirmation that it simply can't be done :[ Thanks and appreciation if you're still with me! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The hiding code should engage when the workbook is SAVED.
*********** Regards, Ron XL2002, WinXP-Pro "I Believe" wrote: Hi All, I need some help in programming my workbook to not open if the user tries to open with macros disabled. As you know, the user can set the security level to "high", "medium", or "low". I would like my workbook to be able to react in the cases where the level is set to "high" or "medium" because in these respectively, any macro will be automatically disabled or the user prompted to opt to either enable or disable all macros. So, should the system automatically disable macros or the user ultimately decide to disable macros when prompted, I need my workbook to react by quickly closing (or not opening at all). My idea was to check what security level is in place: if set to "high" then force the workbook to immediately close again; but if set to "medium" then to capture the user's response event when the system prompts the user, and close the workbook if the choice was to disable macros. Having taken 20mins to write the above succinctly, it has now occured to me that if the system or user disables macros then my code to close the workbook won't work anyway (!!)....or will it. I guess I'm looking for any ideas - or confirmation that it simply can't be done :[ Thanks and appreciation if you're still with me! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Ron, just implemented it and it works a treat! Also noticed users
can't unhide the sheets. Many thanks. "Ron Coderre" wrote: The hiding code should engage when the workbook is SAVED. *********** Regards, Ron XL2002, WinXP-Pro "I Believe" wrote: Hi All, I need some help in programming my workbook to not open if the user tries to open with macros disabled. As you know, the user can set the security level to "high", "medium", or "low". I would like my workbook to be able to react in the cases where the level is set to "high" or "medium" because in these respectively, any macro will be automatically disabled or the user prompted to opt to either enable or disable all macros. So, should the system automatically disable macros or the user ultimately decide to disable macros when prompted, I need my workbook to react by quickly closing (or not opening at all). My idea was to check what security level is in place: if set to "high" then force the workbook to immediately close again; but if set to "medium" then to capture the user's response event when the system prompts the user, and close the workbook if the choice was to disable macros. Having taken 20mins to write the above succinctly, it has now occured to me that if the system or user disables macros then my code to close the workbook won't work anyway (!!)....or will it. I guess I'm looking for any ideas - or confirmation that it simply can't be done :[ Thanks and appreciation if you're still with me! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've the same issue as "I Believe" -- this seems to be a recurring theme. It
would seem that the nice way to handle this would be for Microsoft to allow an option on a workbook that says "Don't open this workbook if the user doesn't enable macros" -- but that's another fish to fry. Ron, your solution seems clever and fine, but with one gap that I don't see how to fix: If the macro (that hides all sheets but one) runs before a save, presumably using the WorkbookBeforeSave event, then how does one then unhide the sheets to allow the user to continue working? I'm presuming that this WorkbookBeforeSave event also gets triggered during autosave, in the middle of a working session. There doesn't seem to be a WorkbookAfterSave event that would allow one to unhide everything. -- Don H. "I Believe" wrote: Thanks Ron, just implemented it and it works a treat! Also noticed users can't unhide the sheets. Many thanks. "Ron Coderre" wrote: The hiding code should engage when the workbook is SAVED. *********** Regards, Ron XL2002, WinXP-Pro "I Believe" wrote: Hi All, I need some help in programming my workbook to not open if the user tries to open with macros disabled. As you know, the user can set the security level to "high", "medium", or "low". I would like my workbook to be able to react in the cases where the level is set to "high" or "medium" because in these respectively, any macro will be automatically disabled or the user prompted to opt to either enable or disable all macros. So, should the system automatically disable macros or the user ultimately decide to disable macros when prompted, I need my workbook to react by quickly closing (or not opening at all). My idea was to check what security level is in place: if set to "high" then force the workbook to immediately close again; but if set to "medium" then to capture the user's response event when the system prompts the user, and close the workbook if the choice was to disable macros. Having taken 20mins to write the above succinctly, it has now occured to me that if the system or user disables macros then my code to close the workbook won't work anyway (!!)....or will it. I guess I'm looking for any ideas - or confirmation that it simply can't be done :[ Thanks and appreciation if you're still with me! |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You could just add more code to the Workbook.Save event to unhide the hidden
sheets so the user could keep working. *********** Regards, Ron XL2002, WinXP "donh" wrote: I've the same issue as "I Believe" -- this seems to be a recurring theme. It would seem that the nice way to handle this would be for Microsoft to allow an option on a workbook that says "Don't open this workbook if the user doesn't enable macros" -- but that's another fish to fry. Ron, your solution seems clever and fine, but with one gap that I don't see how to fix: If the macro (that hides all sheets but one) runs before a save, presumably using the WorkbookBeforeSave event, then how does one then unhide the sheets to allow the user to continue working? I'm presuming that this WorkbookBeforeSave event also gets triggered during autosave, in the middle of a working session. There doesn't seem to be a WorkbookAfterSave event that would allow one to unhide everything. -- Don H. "I Believe" wrote: Thanks Ron, just implemented it and it works a treat! Also noticed users can't unhide the sheets. Many thanks. "Ron Coderre" wrote: The hiding code should engage when the workbook is SAVED. *********** Regards, Ron XL2002, WinXP-Pro "I Believe" wrote: Hi All, I need some help in programming my workbook to not open if the user tries to open with macros disabled. As you know, the user can set the security level to "high", "medium", or "low". I would like my workbook to be able to react in the cases where the level is set to "high" or "medium" because in these respectively, any macro will be automatically disabled or the user prompted to opt to either enable or disable all macros. So, should the system automatically disable macros or the user ultimately decide to disable macros when prompted, I need my workbook to react by quickly closing (or not opening at all). My idea was to check what security level is in place: if set to "high" then force the workbook to immediately close again; but if set to "medium" then to capture the user's response event when the system prompts the user, and close the workbook if the choice was to disable macros. Having taken 20mins to write the above succinctly, it has now occured to me that if the system or user disables macros then my code to close the workbook won't work anyway (!!)....or will it. I guess I'm looking for any ideas - or confirmation that it simply can't be done :[ Thanks and appreciation if you're still with me! |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the quick response, Ron. I think the gap here is that I was
assuming that the BeforeSave macro would hide the sheets and then return to Excel, allowing it to continue the save operation. But I think that it's possible to set a return parameter saying "don't do the save" to Excel -- and then the macro itself could hide the sheets, issue a Save command, and then unhide the sheets. I'll play around with this to see if there is anything peculiar that happens when it's a SaveAs instead of a Save. But the overall scheme seems sound. Thanks again for the help. -- Don H. "Ron Coderre" wrote: You could just add more code to the Workbook.Save event to unhide the hidden sheets so the user could keep working. *********** Regards, Ron XL2002, WinXP "donh" wrote: I've the same issue as "I Believe" -- this seems to be a recurring theme. It would seem that the nice way to handle this would be for Microsoft to allow an option on a workbook that says "Don't open this workbook if the user doesn't enable macros" -- but that's another fish to fry. Ron, your solution seems clever and fine, but with one gap that I don't see how to fix: If the macro (that hides all sheets but one) runs before a save, presumably using the WorkbookBeforeSave event, then how does one then unhide the sheets to allow the user to continue working? I'm presuming that this WorkbookBeforeSave event also gets triggered during autosave, in the middle of a working session. There doesn't seem to be a WorkbookAfterSave event that would allow one to unhide everything. -- Don H. "I Believe" wrote: Thanks Ron, just implemented it and it works a treat! Also noticed users can't unhide the sheets. Many thanks. "Ron Coderre" wrote: The hiding code should engage when the workbook is SAVED. *********** Regards, Ron XL2002, WinXP-Pro "I Believe" wrote: Hi All, I need some help in programming my workbook to not open if the user tries to open with macros disabled. As you know, the user can set the security level to "high", "medium", or "low". I would like my workbook to be able to react in the cases where the level is set to "high" or "medium" because in these respectively, any macro will be automatically disabled or the user prompted to opt to either enable or disable all macros. So, should the system automatically disable macros or the user ultimately decide to disable macros when prompted, I need my workbook to react by quickly closing (or not opening at all). My idea was to check what security level is in place: if set to "high" then force the workbook to immediately close again; but if set to "medium" then to capture the user's response event when the system prompts the user, and close the workbook if the choice was to disable macros. Having taken 20mins to write the above succinctly, it has now occured to me that if the system or user disables macros then my code to close the workbook won't work anyway (!!)....or will it. I guess I'm looking for any ideas - or confirmation that it simply can't be done :[ Thanks and appreciation if you're still with me! |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excel 2002 doesn't have an Autosave operation.
It has an Autorecovery operation but that doesn't save the workbook and overwrite the workbook or trigger the BeforeSave event. Autorecovery just saves a copy of the workbook which is deleted if Excel and the workbook don't crash. Gord Dibben MS Excel MVP On Thu, 5 Jul 2007 08:56:02 -0700, donh wrote: I've the same issue as "I Believe" -- this seems to be a recurring theme. It would seem that the nice way to handle this would be for Microsoft to allow an option on a workbook that says "Don't open this workbook if the user doesn't enable macros" -- but that's another fish to fry. Ron, your solution seems clever and fine, but with one gap that I don't see how to fix: If the macro (that hides all sheets but one) runs before a save, presumably using the WorkbookBeforeSave event, then how does one then unhide the sheets to allow the user to continue working? I'm presuming that this WorkbookBeforeSave event also gets triggered during autosave, in the middle of a working session. There doesn't seem to be a WorkbookAfterSave event that would allow one to unhide everything. |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Gord, you may be correct about Excel 2002, but I'm using Excel 2003, and it
definitely has an autosave. In fact, we advise our users to leave it on, as it means that no matter what bad thing happens to your machine, you will only lose <n minutes of work. Many of our folks set it to about 10 minutes. As you point out, Excel itself often recovers lost work with autorecovery, but that isn't 100% reliable, I don't think. -- Don H. "Gord Dibben" wrote: Excel 2002 doesn't have an Autosave operation. It has an Autorecovery operation but that doesn't save the workbook and overwrite the workbook or trigger the BeforeSave event. Autorecovery just saves a copy of the workbook which is deleted if Excel and the workbook don't crash. Gord Dibben MS Excel MVP On Thu, 5 Jul 2007 08:56:02 -0700, donh wrote: I've the same issue as "I Believe" -- this seems to be a recurring theme. It would seem that the nice way to handle this would be for Microsoft to allow an option on a workbook that says "Don't open this workbook if the user doesn't enable macros" -- but that's another fish to fry. Ron, your solution seems clever and fine, but with one gap that I don't see how to fix: If the macro (that hides all sheets but one) runs before a save, presumably using the WorkbookBeforeSave event, then how does one then unhide the sheets to allow the user to continue working? I'm presuming that this WorkbookBeforeSave event also gets triggered during autosave, in the middle of a working session. There doesn't seem to be a WorkbookAfterSave event that would allow one to unhide everything. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Enable/Disable Macros dialogue box when user opens Excel | Excel Discussion (Misc queries) | |||
How can I disable macros after the initial open? | Excel Discussion (Misc queries) | |||
Open Worbook and Disable Macros | Excel Discussion (Misc queries) | |||
Open Worbook and Disable Macros | Excel Programming | |||
Disable Macros when opening workbook | Excel Programming |