ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Stop macro when open excel from VBA (https://www.excelbanter.com/excel-programming/280222-stop-macro-when-open-excel-vba.html)

Bill Li

Stop macro when open excel from VBA
 
Hello,

I have created a code to open other excel files. However,
in some of the excel files, there are some auto-run macro.
When I open these files via VBA, their auto-run macro will
be executed, which leads to error. If it is possible to
stop these auto-run macro when I open them via VBA. My
excel version is Excel 97 SR-2. The command to open the
file are as following:

Workbooks.Open FileName:="Test.xls",_
updatelinks:=False, _
ReadOnly:=True

Best Regards

Bill


Jim Rech

Stop macro when open excel from VBA
 
If you turn off events before opening the workbook you should be okay.

Application.EnableEvents = False

And then turn events back on.

--
Jim Rech
Excel MVP




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

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