9
votes

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

2

2 Answers

16
votes

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.

6
votes

Check if msxml4.dll exists on your system. and (re-)register the library if it does:

cd %SystemRoot%\system32
regsvr32 /u msxml4.dll
regsvr32 msxml4.dll

You need admin privileges to do this.