fboehlandt
Technical User
Hello everyone
I need to transform an XML file to Excel. The style sheet (XSL) should be applied on import. There appears to be an acknowledged bug:
The workaroudn involves converting XML to HTML first, then to Excel-format. The script is in VBA:
Sub Macro3()
'Load the XML and the XSL (the stylesheet).
Dim oXML As Object, oXSL As Object
Set oXML = CreateObject("MSXML.DOMDocument")
Set oXSL = CreateObject("MSXML.DOMDocument")
oXML.Load "c:\customers.xml"
oXSL.Load "c:\customers.xsl"
'Transform the XML using the stylesheet.
Dim sHTML As String
sHTML = oXML.transformNode(oXSL)
'Save the results to an HTML file.
Open "c:\customers.htm" For Output As #1 '!fails here
Print #1, sHTML
Close #1
'Automate Excel to open the HTML file.
Dim oApp As Excel.Application
Set oApp = CreateObject("excel.application")
oApp.Visible = True
oApp.Workbooks.Open "c:\customers.htm"
End Sub
Converted to VBScript the code fails at the line indicated above, presumably because VBScript does not know the method. I'm not proficient in VBScript so any help is appreciated
I need to transform an XML file to Excel. The style sheet (XSL) should be applied on import. There appears to be an acknowledged bug:
The workaroudn involves converting XML to HTML first, then to Excel-format. The script is in VBA:
Sub Macro3()
'Load the XML and the XSL (the stylesheet).
Dim oXML As Object, oXSL As Object
Set oXML = CreateObject("MSXML.DOMDocument")
Set oXSL = CreateObject("MSXML.DOMDocument")
oXML.Load "c:\customers.xml"
oXSL.Load "c:\customers.xsl"
'Transform the XML using the stylesheet.
Dim sHTML As String
sHTML = oXML.transformNode(oXSL)
'Save the results to an HTML file.
Open "c:\customers.htm" For Output As #1 '!fails here
Print #1, sHTML
Close #1
'Automate Excel to open the HTML file.
Dim oApp As Excel.Application
Set oApp = CreateObject("excel.application")
oApp.Visible = True
oApp.Workbooks.Open "c:\customers.htm"
End Sub
Converted to VBScript the code fails at the line indicated above, presumably because VBScript does not know the method. I'm not proficient in VBScript so any help is appreciated