![]() |
Disable VBA code execution when loading a workbook
How do I control the execution of the VBA Code in a spread sheet when I first
load the workbook. I would like a dialog box to ask if I want to execute the code or not whenI open the workbook? Can any one suggest a way to do that??? -- CharlesM |
Set your macro security to medium.
******************* ~Anne Troy www.OfficeArticles.com "Charles" wrote in message ... How do I control the execution of the VBA Code in a spread sheet when I first load the workbook. I would like a dialog box to ask if I want to execute the code or not whenI open the workbook? Can any one suggest a way to do that??? -- CharlesM |
Charles,
You could use a flag. In module ThisWorkbook: Private Sub Workbook_Open() If MsgBox("Do you want to run the macros?", vbYesNo, "Hey") = vbYes Then MacRun = True End Sub Now in your macros you can test this switch to determine whether to do stuff or not In a general module Public MacRun as Boolean ' This line must be before any subs, ' (and only in one module). Sub whatever() If not MacRun then exit sub .. ' your macro code .. End sub -- Earl Kiosterud www.smokeylake.com "Charles" wrote in message ... How do I control the execution of the VBA Code in a spread sheet when I first load the workbook. I would like a dialog box to ask if I want to execute the code or not whenI open the workbook? Can any one suggest a way to do that??? -- CharlesM |
Security was at medium. Re-set to lowest and the same thing is happening.
-- AusTexRich "Anne Troy" wrote: Set your macro security to medium. ******************* ~Anne Troy www.OfficeArticles.com "Charles" wrote in message ... How do I control the execution of the VBA Code in a spread sheet when I first load the workbook. I would like a dialog box to ask if I want to execute the code or not whenI open the workbook? Can any one suggest a way to do that??? -- CharlesM |
Thanks. I'll make good use of the code.
-- AusTexRich "Earl Kiosterud" wrote: Charles, You could use a flag. In module ThisWorkbook: Private Sub Workbook_Open() If MsgBox("Do you want to run the macros?", vbYesNo, "Hey") = vbYes Then MacRun = True End Sub Now in your macros you can test this switch to determine whether to do stuff or not In a general module Public MacRun as Boolean ' This line must be before any subs, ' (and only in one module). Sub whatever() If not MacRun then exit sub .. ' your macro code .. End sub -- Earl Kiosterud www.smokeylake.com "Charles" wrote in message ... How do I control the execution of the VBA Code in a spread sheet when I first load the workbook. I would like a dialog box to ask if I want to execute the code or not whenI open the workbook? Can any one suggest a way to do that??? -- CharlesM |
All times are GMT +1. The time now is 09:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com