Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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 |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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 |
#5
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change case...help please | Excel Worksheet Functions | |||
Using other workbooks.. | Excel Worksheet Functions | |||
Make Change Case in Excel a format rather than formula | Excel Worksheet Functions | |||
Often-Used Code not working in a new Workbook | Excel Discussion (Misc queries) | |||
Stubborn toolbars in Excel | Excel Discussion (Misc queries) |