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

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.

Who is Participating?
GrahamSkanConnect With a Mentor RetiredCommented:

Shell "Excel ""D:\your folder\yourfile.xml"""
Ryan ChongConnect With a Mentor Commented:
If your xml file is set properly, you can try like:

Shell "Excel D:\yourfolder\yourfile.xml"
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

New_AlexAuthor Commented:
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
New_AlexAuthor Commented:
I think the problem is that I have spaces in the Folder`s Name.

Shell can not handle spaces....

Any ideas?

New_AlexAuthor Commented:
Thanks Guys.

This has to be a share.

Take care
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.