Solved

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

Posted on 2006-11-01
6
592 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

729 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