Solved

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

Posted on 2011-03-17
6
256 Views
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.


 
0
Comment
Question by:New_Alex
  • 3
  • 2
6 Comments
 
LVL 51

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"
0
 
LVL 76

Expert Comment

by:GrahamSkan
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)
'...
    xlWbk.Save
    xlWbk.Close
    xlApp.Quit
End Sub

Open in new window

0
 
LVL 1

Author Comment

by:New_Alex
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
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

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

Shell can not handle spaces....

Any ideas?

Thanks
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 300 total points
ID: 35167740
Try:

Shell "Excel ""D:\your folder\yourfile.xml"""
0
 
LVL 1

Author Closing Comment

by:New_Alex
ID: 35171589
Thanks Guys.

This has to be a share.

Take care
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

820 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