runtime error 91 object variable or with block variable not set

Hi Everyone,

I am using Visual Basic + Web Control for one of my program and the part of the code where i am getting the following code is as follows

error: runtime error 91 object variable or with block variable not set

With wbCtrl.Document.body.Children
.
.
.
   With .Item(jItemNo).rows(1).cells(0).Children 'Error Line
.
.
.
.
   End With
.
.
.
End Width

in the Error Line some times i see that wbCtrl.Document.body.Children : .Item(jItemNo).rows(1).cells(0) has no children. so is there any way I check whether it has children or not so that I can avoid the following code getting run to avoid the runtime error?

Shyam Krishna
shyamkrishnaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
MarshawkConnect With a Mentor Commented:
What about using the all collection length on each object in question, cause if it is zero then there will be no children.

I believe both an HTMLBody and an HTMLTableCell object support the all collection property.


if wbCtrl.Document.body.all.length <> 0 Then.........
 

If yourobject.Item(jItemNo).rows(1).cells(0).all.length <> 0 Then...............
0
 
SethiCommented:
This is becuase you have closed the upper With block with "End Width". Change it to "End With".
0
 
shyamkrishnaAuthor Commented:
sethi thats a simple typing mistake .. how can you expect the comipler to run these lines and not when there are no children for .Item(jItemNo).rows(1).cells(0)?
0
 
SethiCommented:
Post your code, then only will it be possible to tell the source of error. The first reaction came with what I saw in the lines you have typed.
0
 
shyamkrishnaAuthor Commented:
Hey Sethi.. I can understand that. Thank you.

Hey Marshawk.,

   Your answer helped me alot. thanks once again

Shyam Krishna
0
All Courses

From novice to tech pro — start learning today.