Reply to post:

'Microsoft Office has been the bane of my life, while simultaneously keeping me employed'

Hans 1

I inherited an excel workbook that has a macro to read XML data from a database ... it has to run in Excel 2003, 2007, 2010, 2013, and 2016, on the various supported client Windows versions.

You cannot simply use "new MSXML2.SAXXMLReader40", because in newer Office versions, you need version 5 or even 6 ... depending on Windows/Office combination and which version of the DLL is available ...

Any time you changed this, it would fail on one of the target platforms, since this is for customers, you cannot reliably tell which combination they have. Note that Excel plain out crashes on some platforms when you attempt to load the incorrect version, so error handling is futile.

The solution was to use CreateObject with Object variable (late binding) instead of instantiating the object with "new" keyword, iirc, you could then use error handling reliably on all tested platform combinations ... Note that I did not test all possible combinations.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon