View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Matt[_2_] Matt[_2_] is offline
external usenet poster
 
Posts: 6
Default Disable macros on a programmatically opening .xls file

Thanks Dave. I was looking for a way to safely open the file, wipe out it's
entire vba project, and then save it, and run my code on it afterwards since
all these files in question are being uploaded to me from users. My fear was
the Workbook.Open code prior to wiping out the VBA Project inside of it.
Funny I never thought of the OBVIOUS which is Events being False! Darn
testing environments, I always forget the obvious!!

Thanks for the reply, I really appreciate it,
Matt



"Dave Peterson" wrote in message
...
Application.enableevents = false
'your code to open the other workbook
application.enableevents = true

Will stop the Workbook_open event in the other workbook from firing.

You may want to disable events whenever you do something to that other
workbook--you could be firing a worksheet_change or workbook_beforeclose
unintentionally.

Matt wrote:

If I am opening an .xls file using code (VBA), how can I disable the
macro's
from running on it programmatically? I tried ".AutomationSecurity =
msoAutomationSecurityForceDisable" but this kills my macro in the middle
of
itself running as well?

Sorry for the bold, I cant turn it off for some reason.

Matt


--

Dave Peterson

"Dave Peterson" wrote in message
...
Application.enableevents = false
'your code to open the other workbook
application.enableevents = true

Will stop the Workbook_open event in the other workbook from firing.

You may want to disable events whenever you do something to that other
workbook--you could be firing a worksheet_change or workbook_beforeclose
unintentionally.

Matt wrote:

If I am opening an .xls file using code (VBA), how can I disable the
macro's
from running on it programmatically? I tried ".AutomationSecurity =
msoAutomationSecurityForceDisable" but this kills my macro in the middle
of
itself running as well?

Sorry for the bold, I cant turn it off for some reason.

Matt


--

Dave Peterson