ActiveX component can't create object: 'MSXML2.DOMDocument'

Kaja picture Kaja · Apr 23, 2013 · Viewed 33.6k times · Source

I am trying to create an instance of the object Msxml2.DOMDocument.4.0, but I am getting the following error: ActiveX component can't create object: 'MSXML2.DOMDocument'

The error occures in this line: Set xmlDoc = CreateObject("Msxml2.DOMDocument.4.0")

How can I solve this problem?

Thank you for your helps

Answer

Ekkehard.Horner picture Ekkehard.Horner · Apr 23, 2013

Probably the specific version 4.0 of Msxml2.DOMDocument is not (properly) installed on the computer your script runs on. Try to create the version-independent object:

Set xmlDoc = CreateObject("Msxml2.DOMDocument")

This should give you the version that 'works' on your machine. If this fails, try

Set xmlDoc = CreateObject("Msxml2.DOMDocument.6.0")

or experiment with the version number. Use TypeName(xmlDoc) to get a hint wrt the effective version.

P.S. If your problem is caused by 32 vs. 64 bit troubles, this may give you further hints for things to check.