ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable Workbooks_Open() Macro when opening from VBA (https://www.excelbanter.com/excel-programming/381553-disable-workbooks_open-macro-when-opening-vba.html)

DavidUp

Disable Workbooks_Open() Macro when opening from VBA
 
I am trying to open a Workbook "Permanent File Information.xls" from a macro
in another workbook without invoking the workbooks_open macro in "Permanent
File Information.xls"

This is the equivalent of holding down the <shift key whilst opening the
workbook.

I have tried recording two macros to see what the difference is but although
they give different macros they both allow the workbooks_open macro to run
when the two macros are run.

Sub OpenWorkBook()
Workbooks.Open Filename:= _
"F:\Files\Permanent File Information.xls"
End Sub
Sub ShiftOpenWorkbook()
Workbooks.Open Filename:= _
"F:\PA Files\Permanent File Information.xls", Editable:=True
End Sub

Has anyone got any ideas how to stop the workbooks_open macro running from
VBA?

Thank you

Bob Phillips

Disable Workbooks_Open() Macro when opening from VBA
 
Sub OpenWorkBook()
Application.EnableEvents = False
Workbooks.Open Filename:= _
"F:\Files\Permanent File Information.xls"
Application.EnableEvents = True
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"DavidUp" wrote in message
...
I am trying to open a Workbook "Permanent File Information.xls" from a

macro
in another workbook without invoking the workbooks_open macro in

"Permanent
File Information.xls"

This is the equivalent of holding down the <shift key whilst opening the
workbook.

I have tried recording two macros to see what the difference is but

although
they give different macros they both allow the workbooks_open macro to run
when the two macros are run.

Sub OpenWorkBook()
Workbooks.Open Filename:= _
"F:\Files\Permanent File Information.xls"
End Sub
Sub ShiftOpenWorkbook()
Workbooks.Open Filename:= _
"F:\PA Files\Permanent File Information.xls", Editable:=True
End Sub

Has anyone got any ideas how to stop the workbooks_open macro running from
VBA?

Thank you





All times are GMT +1. The time now is 08:49 AM.

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