-
May 17th, 2005, 04:22 AM
#1
Thread Starter
Hyperactive Member
problem in opening XML with EXCEL via VB6
Hello Everybody,
I'm working on a project with XML files.
I have XML file called (for e.g.) myXMLFile.XML
I also have XSL file called (for e.g.) myXSLFile.XSL
When i wrote a VBA Macro in EXCEL it looked like this:
VB Code:
Workbooks.OpenXML Filename:="C:\myXMLFile.XML", Stylesheets:=Array(1)
when i opend the excel with the VBA Macro it didn't ask me how to open the XML file - the xml file was opend automatically with the design that was written in the XSL file.
BUT!!! when i tried to write the same code in VB6 it did'nt work:
VB Code:
objExcel.Workbooks.OpenXML FileName:="C:\myXMLFile.XML", Stylesheets:=Array(1)
the excel poped up the question : how to open the XML File?
How can i open the XML file automatically without the poped question?
Thank you all in advance,
ERAN
Last edited by eranfox; May 17th, 2005 at 04:33 AM.
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
May 17th, 2005, 06:09 AM
#2
Thread Starter
Hyperactive Member
Reply to myself...
Hello Everybody,
I found something that helped me:
http://support.microsoft.com/default...295005&sd=tech
for the lazy programmers here is the code (Add a Reference to the Microsoft XML Version 2.0 Object Library)
VB Code:
Sub ConvertToGeneric()
'Declare three DOMDocument objects.
Dim SourceXML As New DOMDocument
Dim SourceXSL As New DOMDocument
Dim GenericXML As New DOMDocument
'Load the XMLSpreadsheet file into a DOMDocument object.
SourceXML.Load "C:\XMLSpreadhseetFile.xml"
'Load the XSLStyleSheet file into a DOMDocument object.
SourceXSL.Load "C:\XSLSytleSheetFile.xsl"
'Apply the XSL style sheet to the XML spreadsheet file and send it
'to the GenericXML DOMDocument object.
SourceXML.transformNodeToObject Stylesheet:=SourceXSL, _
OutputObject:=GenericXML
'Save the generic XML file as C:\GenericXMLFile.xml
GenericXML.Save ("C:\GenericXMLFile.xml")
End Sub
now with the GenericXMLFile.xml i can open excel via vb6 and it will load the xml file just fine!!!
IF you have some other code regarding to this problem please put it here.
Best Regards,
ERAN
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
May 17th, 2005, 06:15 AM
#3
Thread Starter
Hyperactive Member
Re: problem in opening XML with EXCEL via VB6
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|