BUG: StyleSheets Parameter of the OpenXML Method Ignored When Automating Excel (307230)
The information in this article applies to:
- Microsoft Office Excel 2003
- Microsoft Excel 2002
This article was previously published under Q307230 SYMPTOMS When you call the OpenXML method, your code may be interrupted with the Excel Import XML dialog box. User intervention is required for your code to
continue. This problem occurs when both of the following conditions are met:
- You are calling the OpenXML method from an Automation client.
- You have provided a value for the StyleSheets parameter of the OpenXML method.
RESOLUTION To work around this problem, transform the XML before you
open it in Excel and omit the value for the StyleSheets parameter. To do this, use Microsoft XML (MSXML) to load the XML
and XSL into DOMDocument objects so that you can transform the XML at run time and save
the results to a file. The resulting file can then be opened in Excel without
user intervention.
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
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
STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed at the beginning of this article.
REFERENCES
For additional information about using XML with Microsoft Excel, click the following article numbers to view the articles in the Microsoft Knowledge Base:
288215
INFO: Microsoft Excel 2002 and XML
285891 HOWTO: Use Visual Basic or ASP to create an XML spreadsheet for Excel 2002
Modification Type: | Major | Last Reviewed: | 3/13/2004 |
---|
Keywords: | kbAutomation kbbug KB307230 kbAudDeveloper |
---|
|