ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable macro through automation (https://www.excelbanter.com/excel-programming/279667-disable-macro-through-automation.html)

Scott Wallace

Disable macro through automation
 
Is there a way to disable macros when calling Excel through a language such
as VB.NET? I've got an Excel file that has macros that run on startup. I
don't want the macros to fire when I open through VB. I can't seem to find
a property or setting in Excel that simply says to disable all macros from
running. Yes, I do want to disable all macros either through a setting in
Excel or through the automation, so please - no comments on why I might not
want to do this.

Thanks,
Scott



Trevor Shuttleworth

Disable macro through automation
 
Scott

I think you need:

Application.EnableEvents=False
' your code
Application.EnableEvents=True

or the equivalent in VB.NET

Regards

Trevor


"Scott Wallace" wrote in message
...
Is there a way to disable macros when calling Excel through a language

such
as VB.NET? I've got an Excel file that has macros that run on startup. I
don't want the macros to fire when I open through VB. I can't seem to

find
a property or setting in Excel that simply says to disable all macros from
running. Yes, I do want to disable all macros either through a setting in
Excel or through the automation, so please - no comments on why I might

not
want to do this.

Thanks,
Scott





Scott Wallace

Disable macro through automation
 
That did the trick. Thank you very much!

"Trevor Shuttleworth" wrote in message
...
Scott

I think you need:

Application.EnableEvents=False
' your code
Application.EnableEvents=True

or the equivalent in VB.NET

Regards

Trevor


"Scott Wallace" wrote in message
...
Is there a way to disable macros when calling Excel through a language

such
as VB.NET? I've got an Excel file that has macros that run on startup.

I
don't want the macros to fire when I open through VB. I can't seem to

find
a property or setting in Excel that simply says to disable all macros

from
running. Yes, I do want to disable all macros either through a setting

in
Excel or through the automation, so please - no comments on why I might

not
want to do this.

Thanks,
Scott








All times are GMT +1. The time now is 12:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com