Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

open xml file in excel, save to local share as .xls using  MS access VBA

Posted on 2010-09-01
3
Medium Priority
?
574 Views
Last Modified: 2012-05-10
I have an xml file that needs to be read daily.  I need to :

1.  Download http://Server/folder/FMV_20100831.xml
2.  Have it open in excel (opens fine in excel when refrencing the path)
3.  Have it convert and save to \\server\folder\fmv_daily.xls (excel 97-2003 format)

Is this possible?
0
Comment
Question by:MrAutomate
[X]
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
  • 2
3 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 33583960
which excel version is installed on the machine?
0
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 2000 total points
ID: 33583994
to download file and save it locally use the following function.

taken from http://blog.invisibledenizen.org/2008/11/vba-function-to-download-files.html

usage:

Download_File "http://Server/folder/FMV_20100831.xml", "c:\downloads\FMV_20100831.xml"

***************************************************************

to open xml file in excel, you have 2 options:

Sub Open_XML_File()
Dim oWX As Workbook
Set oWX = Workbooks.OpenXML("c:\downloads\FMV_20100831.xml")
End Sub

Sub Open_XML_File_As_List()
Dim oWX As Workbook
Set oWX = Workbooks.OpenXML(Filename:="c:\downloads\FMV_20100831.xml", LoadOption:=XlXmlLoadOption.xlXmlLoadImportToList)
End Sub

(http://vbadud.blogspot.com/2007/12/open-xml-file-in-excel.html)

***************************************************************
regarding saving the as excel 97-2003 format, you should know that in Excel versions before Excel 2007, code without FileFormat parameter
will not cause too many problems because Excel will use the current FileFormat
of the existing file -- and the default FileFormat for new files is a normal workbook.
however, in Excel 2007-2010 there many file format so you must specify it.
to save it as .xls file in 97-2003 format you should use the following:

 ActiveWorkbook.SaveAs Filename:="\\server\folder\fmv_daily.xls", FileFormat:=xlExcel8
Function Download_File(ByVal vWebFile As String, ByVal vLocalFile As String) As Boolean
Dim oXMLHTTP As Object, i As Long, vFF As Long, oResp() As Byte

'You can also set a ref. to Microsoft XML, and Dim oXMLHTTP as MSXML2.XMLHTTP
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP")
oXMLHTTP.Open "GET", vWebFile, False 'Open socket to get the website
oXMLHTTP.Send 'send request

'Wait for request to finish
Do While oXMLHTTP.readyState <> 4
DoEvents
Loop

oResp = oXMLHTTP.responseBody 'Returns the results as a byte array

'Create local file and save results to it
vFF = FreeFile
If Dir(vLocalFile) <> "" Then Kill vLocalFile
Open vLocalFile For Binary As #vFF
Put #vFF, , oResp
Close #vFF

'Clear memory
Set oXMLHTTP = Nothing
End Function

Open in new window

0
 

Author Closing Comment

by:MrAutomate
ID: 33612827
Sedgwick - Thanks for the response, it gave me exactly what I needed, and it works great!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
New style of hardware planning for Microsoft Exchange server.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

610 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