Automation variable has not been instantiated - IXMLDOMNode

krussellmkrussellm Member Posts: 11

I have the following variable setup in the global variables:

xmlNode : Automation 'Microsoft XML, v6.0'.IXMLDOMNode

I have a report that is run that executes code in a codeunit and it works perfectly.
Here is part of the code that is in question:

xmlNode := xmlNodeList.item(i - 1);

The above code runs from the report executing the codeunit with no errors.

I am trying to run this exact same process in a new codeunit that executes the exact same codeunit as used the report does. I copied over all the code and variables to this new codeunit. This new codeunit does exactly the same thing as the report.
When I run the new codeunit, I get the following error:

"This Automation variable has not been instantiated"

When I run the debugger, the error occurs at this line:
xmlNode := xmlNodeList.item(i - 1);

If I try to do a CREATE on xmlNode (which I read you can't do) I get the error "Cannot create an instance of the OLE or automation server", blah blah blah. I understand that this automation cannot be initialized this way.

My question is how do I make this work when executing from a codeunit and not a report? I have checked the code over and over again and have verified that the codeunit matches with the report.

I am using Dynamics NAV 2009 R2 client with the same version for the database.

Any help would be greatly appreciated.

Thank you,



  • Options
    einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    At first glance, I would say that either the index (i-1) doesn't return a proper node, or your node list isn't instantiated properly. That could be the case if you f.i. create the node list in a codeunit but later on that codeunit goes out of scope and the instance of your node list will be terminated.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
Sign In or Register to comment.