XML declaration in Office 2013

Braulio picture Braulio · Sep 29, 2013 · Viewed 9.1k times · Source

I have the follow VBA code to work with XML using Office 2010:

Public xmlDOM As DOMDocument

Public Sub setXML(xmlFileName As String)

    Set xmlDOM = CreateObject("MSXML.DOMDocument")
    xmlDOM.async = False
    xmlDOM.Load xmlFileName

End Sub

OBS: There is a reference set to Microsoft XML, v6.0

BUT if I open the same code on Office 2013 I got an error that the

Public xmlDOM As DOMDocument

is not declared but there is still the reference to Microsoft XML, v6.0 set.

if I change

Public xmlDOM As DOMDocument

to

Public xmlDOM As MSXML.DOMDocument60

the compiler accepts but running the code I will get an error in

Set xmlDOM = CreateObject("MSXML.DOMDocument") 

even if I change it to

Set xmlDOM = CreateObject("MSXML2.DOMDocument60")

OBS: There is a reference set to Microsoft XML, v6.0 in Office 2013

What is going on?

Answer

Stephenloky picture Stephenloky · Nov 13, 2013

Replace

Public xmlDOM As DOMDocument

with

Public xmlDOM As MSXML2.DOMDocument60

and

Set xmlDOM = CreateObject("MSXML.DOMDocument")

with

Set xmlDOM = New MSXML2.DOMDocument60