我有以下使用Office 2010处理XML的VBA代码:
Public xmlDOM As DOMDocument
Public Sub setXML(xmlFileName As String)
Set xmlDOM = CreateObject("MSXML.DOMDocument")
xmlDOM.async = False
xmlDOM.Load xmlFileName
End Sub
obs:有一个对microsoft xml,v6.0的引用集
但如果我在Office2013上打开相同的代码,我会得到一个错误,即
Public xmlDOM As DOMDocument
未声明,但仍存在对Microsoft XML V6.0集的引用。
如果我改变
Public xmlDOM As DOMDocument
到
Public xmlDOM As MSXML.DOMDocument60
编译器接受但运行的代码会在
Set xmlDOM = CreateObject("MSXML.DOMDocument")
即使我把它改成
Set xmlDOM = CreateObject("MSXML2.DOMDocument60")
OBS:Office 2013中有一个对Microsoft XML V6.0的引用集
怎么回事?
最佳答案
替换
Public xmlDOM As DOMDocument
具有
Public xmlDOM As MSXML2.DOMDocument60
和
Set xmlDOM = CreateObject("MSXML.DOMDocument")
具有
Set xmlDOM = New MSXML2.DOMDocument60