[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 608
  • Last Modified:

Runtime error 91, Object variable not set or with block variable not set

hi
       this is my code below and it throws the error 'Object variable or with block variable not set.'
     
       Global xmlDoc As DOMDocument
       Global intCounter As Integer
       Global xmlDataListTag  As IXMLDOMNodeList
       Global xmlDataTag  As IXMLDOMNodeList
       Global iCounter     As Integer
       Global itX          As IXMLDOMNode
               

       Set xmlDoc = New MSXML2.DOMDocument
       xmlDoc.loadXML strouxml
   
      Set xmlDataListTag = xmlDoc.getElementsByTagName("Exception")
      Set itX = xmlDataListTag.nextNode
      sOutput = itX.selectSingleNode("MainCode").Text---error occurs at this point.

this is very urgent please help me out....


regds
bob
     
     
0
lazziebob
Asked:
lazziebob
1 Solution
 
marchentCommented:
>>Set itX = xmlDataListTag.NextNode
here xmlDataListTag.NextNode returns blank to the itX

~marchent~
0
 
Shiju SasidharanCommented:
Try some extra handling
   
    Set itX = xmlDataListTag.nextNode
    If itX Is Nothing Then
        MsgBox "Node not found"
        Exit Sub ' or Exit Function
    End If
0
 
marchentCommented:
0
 
jkaiosCommented:
Is there a valid element called "MainCode" in the itX object?

If so, is it actually spelled as MainCode or is it in all lowercase or uppercase?
0
 
Lee SavidgeCommented:
Hi,

This error occurs in your situation because on of the objects you're creating is not being created properly. Step through the code with a breakpoint and just hover the mouse over the objects to see which ones are nothing. This line grabs my attention:

Set xmlDataListTag = xmlDoc.getElementsByTagName("Exception")

Firstly, does the node "Exception" exist? If it does, xml is case sensitive, so is it called EXCEPTION, exception, eXcepTion, etc.? If it does exist, does it return anything to xmlDataListTag? It's difficult to give much help without seeing more of the code.

Regards,

Lee
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now