Results 1 to 3 of 3

Thread: problem in opening XML with EXCEL via VB6

  1. #1

    Thread Starter
    Hyperactive Member eranfox's Avatar
    Join Date
    May 2001
    Posts
    492

    Question 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:
    1. 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:
    1. 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...

  2. #2

    Thread Starter
    Hyperactive Member eranfox's Avatar
    Join Date
    May 2001
    Posts
    492

    Thumbs up 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:
    1. Sub ConvertToGeneric()
    2.  
    3.       'Declare three DOMDocument objects.
    4.       Dim SourceXML As New DOMDocument
    5.       Dim SourceXSL As New DOMDocument
    6.       Dim GenericXML As New DOMDocument
    7.  
    8.       'Load the XMLSpreadsheet file into a DOMDocument object.
    9.       SourceXML.Load "C:\XMLSpreadhseetFile.xml"
    10.  
    11.       'Load the XSLStyleSheet file into a DOMDocument object.
    12.       SourceXSL.Load "C:\XSLSytleSheetFile.xsl"
    13.  
    14.       'Apply the XSL style sheet to the XML spreadsheet file and send it
    15.       'to the GenericXML DOMDocument object.
    16.       SourceXML.transformNodeToObject Stylesheet:=SourceXSL, _
    17.       OutputObject:=GenericXML
    18.  
    19.       'Save the generic XML file as C:\GenericXMLFile.xml
    20.       GenericXML.Save ("C:\GenericXMLFile.xml")
    21.  
    22.    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...

  3. #3

    Thread Starter
    Hyperactive Member eranfox's Avatar
    Join Date
    May 2001
    Posts
    492

    Re: problem in opening XML with EXCEL via VB6

    Hello again,
    Also look at :
    http://support.microsoft.com/default...b;en-us;285891

    Best Regards,
    ERAN
    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
  •  



Click Here to Expand Forum to Full Width