UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> XmlToXls    

' XmlToXls
' http://www.utteraccess.com/wiki/index.php/FunctionNameHere
' Code courtesy of UtterAccess Wiki
' Original submission by Diego F.Pereira-Perdomo
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
' You are free to use this code in any application,
' provided this notice is left unchanged.
' rev  date                          brief descripton
' 1.0  2012-07-10                    Imports an XML file to Excel using xlXmlLoadImportToList (LoadOption:=2).
'                                       xmlPath: The path of the XML File
'                                       xlsPath: The path in which the Excel File is going to be saved.
Public Function XmlToXls(xmlPath As String, _
                        xlsPath As String)

On Error GoTo ErrorHandler

Dim xlApp   As Object
Dim xlWb    As Object

   Set xlApp = CreateObject("Excel.Application")

   With xlApp
       .DisplayAlerts = False
       Set xlWb = .Workbooks.OpenXML(FileName:=xmlPath, LoadOption:=2)
       .DisplayAlerts = True
       xlWb.SaveAs (xlsPath)

   End With

If Not xlApp Is Nothing Then
End If

Set xlWb = Nothing
Set xlApp = Nothing

Exit Function

Select Case Err.Number
   Case 0
   Case Else
       MsgBox Err.Number & ": " & Err.Description
       Resume ExitFunction
End Select
End Function

Creative Commons License
XmlToXls by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search

Thank you for your support!
This page has been accessed 3,315 times.  This page was last modified 07:02, 10 July 2012 by dipetete.   Disclaimers