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
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?
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
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.
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