I am trying to import xml data into excel.. So the first line of the code is
Dim XMLDOC As MSXML2.DOMDocument
and this gives an error "user defined type not defined"
Object Required in Excel VBA. Object required is an error which is caused at run time when we have defined any variable which is not an object but we try to assign some values using a SET statement. This error is a run time error that arises for various reasons.
Inside the VBE, Go to Tools -> References, then Select Microsoft XML, v6.0 (or whatever your latest is. This will give you access to the XML Object Library.
Updated with fancy pic!
I had DOMDocument
defined which needed Microsoft XML, v3.0
but I had Microsoft XML, v6.0
selected in references which caused the below error
"user defined type not defined".
The solution
The solution was to either change DOMDocument
to DOMDocument60
(60 uses ver 6.0) or use the Microsoft XML, v3.0
reference with DomDocument
.
Just a quick note, if anyone is using a different version, such as Microsoft XML, v4.0, then DOMDocument40
should be used. This is because the number at the end of the DOMDocument
is specific to the version of the library being used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With