How can I force VBA for word to Launch an .xml file only in Excel?

Posted on 2011-03-17
Last Modified: 2012-08-13
I am in VBA for word editor.

How can I specify that I want to Launch an external .xml file only in Excel from VBA in Word?

In windows, the .xml is not associated to open with excel. Which command parameters do I use?

Thanks in advance.
Full points given for this.

Question by:New_Alex
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 52

Assisted Solution

by:Ryan Chong
Ryan Chong earned 200 total points
ID: 35154652
If your xml file is set properly, you can try like:

Shell "Excel D:\yourfolder\yourfile.xml"
LVL 76

Expert Comment

ID: 35154874
If you need to work on the workbook in your VBA, you will need to capture the objects.
Sub OpenForExcel()
    Dim xlApp As Excel.Application
    Dim xlWbk As Excel.Workbook
    Dim xlWks As Excel.Worksheet
    Dim strFileName As String
    strFileName = "C:\MyFolder\MyFile.xlm"
    On Error Resume Next
    Set xlApp = GetObject(, "Excel.Application")
    On Error GoTo 0
    If xlApp Is Nothing Then
        Set xlApp = CreateObject("Excel.Application")
    End If
    xlApp.Visible = True
    Set xlWbk = xlApp.Workbooks.Open(strFileName)
    Set xlWks = xlWbk.Sheets(1)
End Sub

Open in new window


Author Comment

ID: 35163676
Thanks GrahamSkan: but I need just a simple line just to open the .xml file into excel.

ryancys method looks fine but for some reason it does not work
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.


Author Comment

ID: 35163712
I think the problem is that I have spaces in the Folder`s Name.

Shell can not handle spaces....

Any ideas?

LVL 76

Accepted Solution

GrahamSkan earned 300 total points
ID: 35167740

Shell "Excel ""D:\your folder\yourfile.xml"""

Author Closing Comment

ID: 35171589
Thanks Guys.

This has to be a share.

Take care

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

617 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