Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Disable macros on a programmatically opening .xls file

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


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Disable macros on a programmatically opening .xls file

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
  #3   Report Post  
Posted to microsoft.public.excel.misc
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros Disabled when opening file snax500 Excel Discussion (Misc queries) 1 October 19th 06 09:37 PM
"openinf file..."ENABLE MACROS...DISABLE MACROS" F. Lawrence Kulchar Excel Discussion (Misc queries) 3 September 12th 06 10:33 AM
Disable Macros --> Close File [email protected] Setting up and Configuration of Excel 3 August 24th 05 10:22 PM
Opening a file and enabling macros automatically Fernandoalberte Excel Discussion (Misc queries) 1 June 29th 05 12:31 PM
Trouble opening an Excel file that contains macros JohnR Excel Worksheet Functions 1 March 8th 05 08:09 PM


All times are GMT +1. The time now is 09:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"