Open an Excel Workbook using word VBA

Posted on 2006-06-02
Last Modified: 2012-06-27
I am currently preparing a template generator using Word VBA.

The Userform consists of option boxes and the programming behind the boxes simply tells it to open the files.  This works perfectly for Word documents.

However, whenever i give it a path relating to an excel spreadsheet it simply crashes.  I am a novice at vba!

Could someone provide a vba example of how to open a specific workbook in excel from word and make it appear in a normal excel window and visible?

I am creating quite a few template generators in the near future and this would be very helpful.

Many thanks
Question by:stuardo
    1 Comment
    LVL 44

    Accepted Solution

    Hi stuardo,

    you could try something like calling this sub in the button click and change the filename to something that works for you of course

    Sub OpenXlFile()
    Dim xlObj As Object
    Dim xlWbk As Object

      Set xlObj = CreateObject("Excel.Application")
      Set xlWbk = xlObj.Workbooks.Open("c:\temp.xls")
      xlObj.Visible = True

    End Sub

    share what you know, learn what you don't

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
    This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
    This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
    Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now