Solved

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

Posted on 2006-11-01
6
588 Views
Last Modified: 2013-12-26
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
Comment
Question by:lazziebob
6 Comments
 
LVL 13

Expert Comment

by:marchent
ID: 17855289
>>Set itX = xmlDataListTag.NextNode
here xmlDataListTag.NextNode returns blank to the itX

~marchent~
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 17855544
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
 
LVL 13

Expert Comment

by:marchent
ID: 17855566
0
 
LVL 12

Expert Comment

by:jkaios
ID: 17895348
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
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 500 total points
ID: 17914494
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question