logo

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

Jebe posted on Friday, February 09, 2007 8: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.
reply


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

ct6 posted on Friday, July 13, 2007 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)
reply


Didn't Find The Answer You Were Looking For?

View Excel Programming Posts   Ask A New Question

EggHeadCafe has experts online right now that may know the answer to your question.  We pay them a bonus for answering as many questions as they can.  So, why not help them and yourself by becoming a member (free) and ask them your question right now?
Ask Question In Live Forum

If you have an OpenID and do not want to become a member of the EggHeadCafe forum, you can also sign on to Chat Chaos and post your question to our real time Silverlight chat application.
Ask Question In Chat Chaos


Developer Outlook AddIns    Excel    Excel Charting    Excel Crashes GPFs    Excel Miscellaneous    Excel New Users    Excel Programming    Excel Setup    Excel Worksheet    Groove    MAC Office    MAC Office Entourage    MAC Office Word    Office Communicator    Office Developer Automation    Office COM Add-Ins    Office Developer Other    Office Outlook Forms    Office Outlook VBA    Office Developer VBA    Office Miscellaneous    Office Setup    Office Templates Misc    Office Update    One Note    Outlook    Outlook BCM    Outlook Calendaring    Outlook Contacts    Outlook Fax    Outlook General    Outlook Installation    Outlook Interop    Outlook MAC    Outlook Printing    Outlook Program Add-Ins    Outlook Program Forms    Outlook Program VBA    Outlook 3rd Party Utility    Outlook Express    PowerPoint    Project    Project Developer    Project Server    Visio    Visio Developer    Visio General    Word Application Errors    Word Conversions    Word Menus Toolbars    Word Document Management    Word Drawing Graphics    Word International Features    Word mail    Word Mail Merge Fields    Word New Users    Word Numbering    Word OLE Interop    Word Page Layout    Word Printing Fonts    Word Programming    Word Setup Networking    Word Spelling Grammar    Word Tables    Word VBA Add-Ins    Word VBA Beginners    Word VBA Customization    Word VBA    Word VBA User Forms    Works Windows   






  $1000 Contest    [)ia6l0 iii - $231  |  Jonathan VH - $153  |  Huggy Bear - $133  |  egg egg - $100  |  F Cali - $93  |  more Advertise  |  Privacy  |   (c) 2010