OpenXML Method

Microsoft Excel Visual Basic

OpenXML Method

       

Returns a Workbook object representing an XML file in Microsoft Excel.

expression.OpenXML(FileName, Stylesheets)

expression   Required. An expression that returns one of the objects in the Applies To list.

FileName  Required String. The name of the file to open.

Stylesheets  Optional Variant. Either a single value or an array of values specifying which XSLT stylesheet processing instructions to apply.

Example

In this example, Microsoft Excel loads the XML file "customers.xml" and applies the first XSLT stylesheet. If the resulting file is XML, it will apply the second XSLT stylesheet processing instruction in the newly transformed file. Finally, if the resulting file is again XML, it will apply the fifth XSLT stylesheet processing instruction. The results are then loaded into Excel and become either an XML-Spreadsheet or a flattened XML. This example assumes the "customers.xml" file exists.

Sub UseOpenXML()

    Application.Workbooks.OpenXML _
        Filename:="customers.xml", Stylesheets:=Array(1, 2, 5)

End Sub