Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Cause workbook to fail to open if user opts to disable macros

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Cause workbook to fail to open if user opts to disable macros

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default correction....on save, not on close

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default correction....on save, not on close

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default correction....on save, not on close

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 698
Default correction....on save, not on close

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default correction....on save, not on close

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default correction....on save, not on close

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default correction....on save, not on close

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
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
Enable/Disable Macros dialogue box when user opens Excel David Excel Discussion (Misc queries) 2 August 23rd 06 02:21 PM
How can I disable macros after the initial open? Troy Excel Discussion (Misc queries) 4 February 13th 06 03:38 PM
Open Worbook and Disable Macros DMc2005 Excel Discussion (Misc queries) 4 October 1st 05 07:23 PM
Open Worbook and Disable Macros DMc2005 Excel Programming 4 October 1st 05 07:23 PM
Disable Macros when opening workbook Rob[_21_] Excel Programming 7 November 12th 04 09:22 AM


All times are GMT +1. The time now is 03:13 AM.

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"