Workbook
(1)
Incorrect
(1)
Logic
(1)
Macro
(1)
Event
(1)
Updates
(1)
Sheet
(1)
Retype
(1)

Can you tell me how to open the workbook by VBA?

Asked By Jebe
09-Feb-07 08:46 AM
Can you tell me how to open the workbook by VBA? I have incorrect logic in
the macro which is run in the open event, so my macro updates the wrong
sheet. I don't want to have to retype all the correct informaton in this
sheet so I'd like to disable this macro and then fix it.

Hi Jebeh -I know you posted this awhile ago, but I found Chip Pearson's answer

Asked By ct6
13-Jul-07 11:00 AM
Hi Jebeh -

I know you posted this awhile ago, but I found Chip Pearson's answer useful
and saw your post so I decided to try to help.

The general was to open a workbook in VBA is

Workbooks.Open(fileName)

As far as disabling macros to open the workbook, you can probably get away
with

Application.EnableEvents=False
Workbooks.Open(fileName)


However, here is an even fancier way that I came up with and works really
well.  This uses Excel Automation.  Try This:

Sub test_Automation_Open_WB()
Dim XL As Excel.Application
Dim wb As Workbook
Dim fileName As String
Dim wb_Name As String

wb_Name = "TEST__someStuff.xls"

fileName = ThisWorkbook.Path & "\" & wb_Name

Set XL = CreateObject("Excel.Application")

With XL
.EnableEvents = False
.Visible = True

Set wb = XL.Workbooks.Open(fileName, False)
End With
End Sub

This should easily do all you need.  It will open a new application of Excel
and then your workbook and will suppress all workbook.open events and pop-ups
to disable macros, etc.

Hope that helps,

Best Regards,

Chris (ct60@aol.com)
Post Question To EggHeadCafe