Solved

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

Posted on 2006-11-01
6
585 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now