DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: problem in opening XML with EXCEL via VB6

  1. #1
    Join Date
    May 2005
    Posts
    3

    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:

    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:


    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

  2. #2
    Join Date
    May 2005
    Posts
    3

    Thumbs up Reply to myself...

    Hello Everybody,
    I found something that helped me:
    http://support.microsoft.com/default.aspx?scid=kb;en-us;295005&sd=tech

    for the lazy programmers here is the code (Add a Reference to the Microsoft XML Version 2.0 Object Library)
    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

  3. #3
    Join Date
    May 2005
    Posts
    3

    Another Article

    Hello again,
    Also look at :

    http://support.microsoft.com/default...b;en-us;285891
    Best Regards,
    ERAN
    Last edited by eranfox; 05-17-2005 at 07:20 AM.

  4. #4
    Join Date
    Feb 2004
    Location
    Colton, CA
    Posts
    550
    Good find :thumbs:

  5. #5
    Join Date
    Aug 2007
    Posts
    1
    Hi

    I saw the code posted here for converting xml spreadsheet into xml. It uses a stylesheet. I was wondering where did you get the style sheet from or whether you wrote it yourself.

    thanks
    Varun
    EMail Address Removed By Mod
    Last edited by Hack; 08-09-2007 at 07:17 AM. Reason: Removed EMail Address

  6. #6
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Welcome to DevX.

    I have edited your post and removed your email address.

    You should never post your email address in an open post on an open forum. Mail spam bots can pick that up and before you know it, your mailbox is full of junk mail. If you wish to share your email address with other forum members, please do so via our PM system.

    In addition, we prefer all answers to questions be publically posted rather than sent via EMail or PM. That way, everyone with a similar problem can benefit.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center