Solved

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

Posted on 2011-03-17
6
252 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 49

Assisted Solution

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

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

Expert Comment

by:GrahamSkan
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Comment

by:New_Alex
Comment Utility
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
Comment Utility
Try:

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

Author Closing Comment

by:New_Alex
Comment Utility
Thanks Guys.

This has to be a share.

Take care
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

11 Experts available now in Live!

Get 1:1 Help Now