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.


 
LVL 1
New_AlexAsked:
Who is Participating?
 
GrahamSkanConnect With a Mentor RetiredCommented:
Try:

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

Shell "Excel D:\yourfolder\yourfile.xml"
0
 
GrahamSkanRetiredCommented:
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)
'...
    xlWbk.Save
    xlWbk.Close
    xlApp.Quit
End Sub

Open in new window

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

Shell can not handle spaces....

Any ideas?

Thanks
0
 
New_AlexAuthor Commented:
Thanks Guys.

This has to be a share.

Take care
0
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.