View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Sharad Naik Sharad Naik is offline
external usenet poster
 
Posts: 212
Default Turn Off Macros With Workbook Open

Add a Command button in the sheet, with title 'Disable Macro".
When it is clicked, in the code for command button click,
change value of a public variable, (say set it to 100) (public variable
should be defined at module level.).
In Before_Close code, at the begining check the value of this public
variable, if it is 100 then exit sub.

Sharad
"Paul Moles" wrote in message
...
I have a workbook with complementary Auto_Open and Workbook_BeforeClose
code.

Part of Auto_Open ensures macros are enabled. With Workbook_BeforeClose
resetting the workbook for when it is next opened.

Question having opened a workbook with macros enabled can a user then turn
them off sometime during the use of the book, thereby disabling my
Workbook_BeforeClose code. (Access to Macro code is password protected)

Could not find correct placement/syntax for Application.EnableCancelKey -
xlDisabled. but having tried Ctrl+Break, it has no effect as these macros
are
not actually running while the book is in use.

Many Thanks
Paul Moles