DemonForce
asked on
Excel Macro to read xml file from web
Hi,
I have several workbooks that need to access an XML file called config.xml from a website, say website.co.uk, although all the workbooks access the same config.xml it needs to have independent sections for each of them, so I can define version numbers initially followed by other data later on...
Therefore, how do I create a excel macro that will access this file, and check version number so I can compare if its latest version, how would I access the individual workbook versions from the xml, and how would the xml be laid out?
Cheers
I have several workbooks that need to access an XML file called config.xml from a website, say website.co.uk, although all the workbooks access the same config.xml it needs to have independent sections for each of them, so I can define version numbers initially followed by other data later on...
Therefore, how do I create a excel macro that will access this file, and check version number so I can compare if its latest version, how would I access the individual workbook versions from the xml, and how would the xml be laid out?
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Seems perfect thank you for the examples, I assume by editing fSuccess = oDoc.Load(ActiveWorkbook.P ath & "\config.xml") I can get it to take the config.xml from any website?
Thanks
Thanks
That's correct. The load argument can either be a path or url
ASKER
Ok, been playing around with it and have put more data into the xml, and have it loading the data on worksheet open, however... When I load the sheet there is a delay as it is loading the data from the file in, and then nothing is displayed on screen until I call the routine from a button attached to the main macro.
It would appear to me that it is loading the data and continues into macro, as it currently does not have data the criteria is not matched so therefore does not show, until it is activated second time?
It would appear to me that it is loading the data and continues into macro, as it currently does not have data the criteria is not matched so therefore does not show, until it is activated second time?
ASKER
Right, took the ELSE out and it works perfect now, cheers.
ASKER
Hi,
I downloaded and extensively modified your example that you supplied for reading in XML. For some reason when I export the code, and import elsewhere I get an error related to this part...
Dim oDoc As DOMDocument
Compile error:
User-defined type not defined
Always works fine in supplied example.
I downloaded and extensively modified your example that you supplied for reading in XML. For some reason when I export the code, and import elsewhere I get an error related to this part...
Dim oDoc As DOMDocument
Compile error:
User-defined type not defined
Always works fine in supplied example.
Did you add the reference to msxml?
Open in new window
You'll have a better idea than me about what fields you'd need but I've started with 3: Version, Title and an ID attribute. A numeric ID that is unique to the workbook is going to be the best way to compare and retrieve data for the workbook requesting it.
sample code to load the xml (need reference to MSXML library)
Open in new window