Question

In a previous post I was looking to find a way to manipulate XML, and an answer was provided by David that looked very promising. However, I have been having a small issue when it comes to the following line:

Set Entity = DOM.DocumentElement.getElementsByTagName("EntityId")(0)

where by EntityId I actually meant entityId (to preserve continuity I have left the code as is).

Namely I get the following error: Object variable / with block variable not set.

Now, I found this post, which outlined a potential solution, but I have the MSXML 6.0 reference box checked. I have also confirmed, as that poster did, that the tag does exist in the XML document I am referencing. Is there another reason this could be happening outside of user error?

EDIT: Screenshot of entityId:

enter image description here

Was it helpful?

Solution

The only way I can replicate your error is by making an XML file which is invalid/doesn't parse.

Your XML file is broken. Fix it, and the code will work.

Put a breakpoint on the Set entity line, and then examin the DOM.parseError in the Locals window.

enter image description here

This will indicate whether there are problems with your XML file that prevent it from parsing.

When the xml file cannot be parsed, the DOM.DocumentElement is Nothing, and that will raise the Object Required error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top