4

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?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Braulio
  • 535
  • 1
  • 8
  • 18
  • Is your Excel 2013 64-bit and your Excel 2010 32-bit? Are they both on the same OS version? – Tim Williams Sep 29 '13 at 20:21
  • Hi! Yes, one is 64-bit (2013) and other is 32-bits (2010). But I found a solution, I replaced "Public xmlDOM As DOMDocument" by "Public xmlDOM As MSXML2.DOMDocument60" and "Set xmlDOM = CreateObject("MSXML.DOMDocument")" by "Set xmlDOM = New MSXML2.DOMDocument60", it's working now fine for both versions – Braulio Oct 01 '13 at 04:22
  • @Braulio You may move the answer from comment to answer section so that it can be helpful for future readers. – Santosh Oct 02 '13 at 18:44

1 Answers1

8

Replace

Public xmlDOM As DOMDocument

with

Public xmlDOM As MSXML2.DOMDocument60

and

Set xmlDOM = CreateObject("MSXML.DOMDocument")

with

Set xmlDOM = New MSXML2.DOMDocument60
sirdank
  • 3,351
  • 3
  • 25
  • 58
Stephenloky
  • 413
  • 8
  • 21