Disable macros on a programmatically opening .xls file

M

Matt

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
 
D

Dave Peterson

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.
 
M

Matt

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top