Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML declaration in Office 2013

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?

like image 856
Braulio Avatar asked Feb 16 '23 03:02

Braulio


1 Answers

Replace

Public xmlDOM As DOMDocument

with

Public xmlDOM As MSXML2.DOMDocument60

and

Set xmlDOM = CreateObject("MSXML.DOMDocument")

with

Set xmlDOM = New MSXML2.DOMDocument60
like image 55
Stephenloky Avatar answered Feb 24 '23 02:02

Stephenloky