ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Event (https://www.excelbanter.com/excel-programming/318198-open-event.html)

Andy

Open Event
 
Anyone know how to open a work book through code and suppress the any code
that is in the open event of the book being opened?

I know you can do it manually by holding the shift key to go into design
mode so there must be a VBA equivalent mustn't there?

Ron de Bruin

Open Event
 
Hi Andy

Use EnableEvents

Sub test()
Application.EnableEvents = False
Workbooks.Open "C:\Data\test1.xls"
Application.EnableEvents = True
End Sub


Or put your code in this sub

Sub Auto_open()

End Sub

Must be in a normal module
If you use a Auto_open macro then this wil not run if you open the file with a macro



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Andy" wrote in message ...
Anyone know how to open a work book through code and suppress the any code
that is in the open event of the book being opened?

I know you can do it manually by holding the shift key to go into design
mode so there must be a VBA equivalent mustn't there?




Andy

Open Event
 
Thanks Ron

Andy



"Ron de Bruin" wrote:

Hi Andy

Use EnableEvents

Sub test()
Application.EnableEvents = False
Workbooks.Open "C:\Data\test1.xls"
Application.EnableEvents = True
End Sub


Or put your code in this sub

Sub Auto_open()

End Sub

Must be in a normal module
If you use a Auto_open macro then this wil not run if you open the file with a macro



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Andy" wrote in message ...
Anyone know how to open a work book through code and suppress the any code
that is in the open event of the book being opened?

I know you can do it manually by holding the shift key to go into design
mode so there must be a VBA equivalent mustn't there?






All times are GMT +1. The time now is 02:09 PM.

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