Results 1 to 5 of 5

Thread: VSTO 2005 - xml into Excel

  1. #1

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    VSTO 2005 - xml into Excel

    How can I open an xml file into the existing workbook, and not open a new workbook? I have this code
    Code:
    Globals.ThisWorkbook.Application.Workbooks.OpenXML(
                    @"c:\temp\SportsFeed.xml",
                    System.Type.Missing,
                    XlXmlLoadOption.xlXmlLoadImportToList);
    But it opens a new workbook, I'd really like the xml list to show up in the already open "Sheet1".

    Thanks,
    Mike

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: VSTO 2005 - xml into Excel

    That is the default action of the .OpenXML function. How about opening it hidden and then .Copy the Sheet over to your desired Workbook?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: VSTO 2005 - xml into Excel

    That would probably work for me. I'm not that familiar with office programming, and don't see how to open it hidden - it's not an option for .OpenXml is it? Could you point me to a link or something that shows how to do this?

    Thanks,
    Mike

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: VSTO 2005 - xml into Excel

    If you want to load the data from a XML file into an existing workbook, rather than creating a new one, you should use the XmlImport method of the existing workbook.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: VSTO 2005 - xml into Excel

    That looks promising too, but I'm struggling. Reason is, the xml I'm given does not have a schema, and XmlImport requires one.

    Maybe I should rephrase my question. I have some xml, either in a file or as a string in memory. I'd like to put that xml in Sheet1 at A1 and have it show as an xml list.

    Thanks again,
    Mike

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