Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA:MSXML2.DOMDocument changed to MSXML2.DOMDocument40 in macro

Tags:

vba

I recently changed "MSXML2.DOMDocument" to "MSXML2.DOMDocument40" because of some reason.It works in my Computer.But the same code doesnt work in another computer. What might be the reason? Please suggest some answer.

like image 252
user1495475 Avatar asked Oct 11 '12 11:10

user1495475


1 Answers

MSXML2.DOMDocument is always a synonym for MSXML2.DOMDocument30. This corresponds to the library referenced by "Microsoft XML, v3.0" in VBA (msxml3.dll)

Microsoft recommend that developers should target the "Microsoft XML, v6.0" library (msxml6.dll) in their applications. This would be done by setting a reference to that library and then using the appropriate types - e.g. MSXML2.DOMDocument60.

If using the v6.0 library is not possible then developers should fall back on the "Microsoft XML, v3.0" library (msxml3.dll) instead.

Using any other version of the XML library is not recommended as there is no guarantee that any versions other than v6.0 and v3.0 will be available on a given system. The MSXML2.DOMDocument40 which you used corresponds to the "Microsoft XML, v4.0" library (msxml4.dll) and it is very likely that the computer where this code doesn't run simply doesn't have that library available.

For full details see http://blogs.msdn.com/b/xmlteam/archive/2006/10/23/using-the-right-version-of-msxml-in-internet-explorer.aspx

edit: if using late binding, you can find the appropriate ProgIDs here. For DOMDocument60, you would use CreateObject("Msxml2.DOMDocument.6.0")

like image 84
barrowc Avatar answered Dec 28 '22 22:12

barrowc