Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default object variable not set

why does this not work?
Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Do
Set o = a.Item(D)
Sheets("Sheet3").Range("D1") = o.innertext
Sheets("Sheet3").Range("D2") = Len(Sheets("Sheet3").Range("D1"))
If Sheets("Sheet3").Range("D2") < 7 Then D = D + 1
Loop Until Sheets("Sheet3").Range("D2") = 7

and yet this works fine?
D = 10
Do

Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Set o = a.Item(D)
ActiveCell = o.innertext
If ActiveCell = "" Then D = D + 1
Loop Until ActiveCell < ""
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

ActiveCell = o.innertext
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

I get object variable not set on the upper example! Im trying to get it to
search a range of items in a web page and return the first one with seven
characters (a post code ie 6 character and one space!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default object variable not set

I think it is because in your second code "D" has a value.

D =10
Set o = a.Item(D)

but, in your first code

D=?
Set o = a.Item(D)

Is D a Long Data Type? If so, maybe your code is having problems with
trying to find Item(0)?
--
Cheers,
Ryan


"Atishoo" wrote:

why does this not work?
Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Do
Set o = a.Item(D)
Sheets("Sheet3").Range("D1") = o.innertext
Sheets("Sheet3").Range("D2") = Len(Sheets("Sheet3").Range("D1"))
If Sheets("Sheet3").Range("D2") < 7 Then D = D + 1
Loop Until Sheets("Sheet3").Range("D2") = 7

and yet this works fine?
D = 10
Do

Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Set o = a.Item(D)
ActiveCell = o.innertext
If ActiveCell = "" Then D = D + 1
Loop Until ActiveCell < ""
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

ActiveCell = o.innertext
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

I get object variable not set on the upper example! Im trying to get it to
search a range of items in a web page and return the first one with seven
characters (a post code ie 6 character and one space!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default object variable not set

sorry just forgot to copy that part of the code into my question d is set to
10 on both codes!

"Ryan H" wrote:

I think it is because in your second code "D" has a value.

D =10
Set o = a.Item(D)

but, in your first code

D=?
Set o = a.Item(D)

Is D a Long Data Type? If so, maybe your code is having problems with
trying to find Item(0)?
--
Cheers,
Ryan


"Atishoo" wrote:

why does this not work?
Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Do
Set o = a.Item(D)
Sheets("Sheet3").Range("D1") = o.innertext
Sheets("Sheet3").Range("D2") = Len(Sheets("Sheet3").Range("D1"))
If Sheets("Sheet3").Range("D2") < 7 Then D = D + 1
Loop Until Sheets("Sheet3").Range("D2") = 7

and yet this works fine?
D = 10
Do

Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Set o = a.Item(D)
ActiveCell = o.innertext
If ActiveCell = "" Then D = D + 1
Loop Until ActiveCell < ""
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

ActiveCell = o.innertext
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

I get object variable not set on the upper example! Im trying to get it to
search a range of items in a web page and return the first one with seven
characters (a post code ie 6 character and one space!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default object variable not set

Its the o.innertext that it doesnt seem to like! but it tolerates it in the
earlier example?

"Ryan H" wrote:

I think it is because in your second code "D" has a value.

D =10
Set o = a.Item(D)

but, in your first code

D=?
Set o = a.Item(D)

Is D a Long Data Type? If so, maybe your code is having problems with
trying to find Item(0)?
--
Cheers,
Ryan


"Atishoo" wrote:

why does this not work?
Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Do
Set o = a.Item(D)
Sheets("Sheet3").Range("D1") = o.innertext
Sheets("Sheet3").Range("D2") = Len(Sheets("Sheet3").Range("D1"))
If Sheets("Sheet3").Range("D2") < 7 Then D = D + 1
Loop Until Sheets("Sheet3").Range("D2") = 7

and yet this works fine?
D = 10
Do

Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Set o = a.Item(D)
ActiveCell = o.innertext
If ActiveCell = "" Then D = D + 1
Loop Until ActiveCell < ""
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

ActiveCell = o.innertext
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

I get object variable not set on the upper example! Im trying to get it to
search a range of items in a web page and return the first one with seven
characters (a post code ie 6 character and one space!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default object variable not set

I would post the full code if possible along with how you declared your
variables.
--
Cheers,
Ryan


"Atishoo" wrote:

Its the o.innertext that it doesnt seem to like! but it tolerates it in the
earlier example?

"Ryan H" wrote:

I think it is because in your second code "D" has a value.

D =10
Set o = a.Item(D)

but, in your first code

D=?
Set o = a.Item(D)

Is D a Long Data Type? If so, maybe your code is having problems with
trying to find Item(0)?
--
Cheers,
Ryan


"Atishoo" wrote:

why does this not work?
Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Do
Set o = a.Item(D)
Sheets("Sheet3").Range("D1") = o.innertext
Sheets("Sheet3").Range("D2") = Len(Sheets("Sheet3").Range("D1"))
If Sheets("Sheet3").Range("D2") < 7 Then D = D + 1
Loop Until Sheets("Sheet3").Range("D2") = 7

and yet this works fine?
D = 10
Do

Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Set o = a.Item(D)
ActiveCell = o.innertext
If ActiveCell = "" Then D = D + 1
Loop Until ActiveCell < ""
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

ActiveCell = o.innertext
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

I get object variable not set on the upper example! Im trying to get it to
search a range of items in a web page and return the first one with seven
characters (a post code ie 6 character and one space!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default object variable not set


Dim allTD, td, tdOK

Set allTD = WebBrowser2.Document.frames
("fraSUTop").Document.getelementsbytagname("TD" )

For Each td In allTD
If Len(td.innertext) = 7 Then
Set tdOK = td
Exit For
End If
Next td

'then do something with tdOK

Tim



On Dec 17, 5:25*am, Atishoo wrote:
why does this not work?
Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Do
Set o = a.Item(D)
Sheets("Sheet3").Range("D1") = o.innertext
Sheets("Sheet3").Range("D2") = Len(Sheets("Sheet3").Range("D1"))
If Sheets("Sheet3").Range("D2") < 7 Then D = D + 1
Loop Until Sheets("Sheet3").Range("D2") = 7

and yet this works fine?
D = 10
Do

Set a =
WebBrowser2.Document.frames("fraSUTop").Document.g etelementsbytagname("TD")
Set o = a.Item(D)
ActiveCell = o.innertext
If ActiveCell = "" Then D = D + 1
Loop Until ActiveCell < ""
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

ActiveCell = o.innertext
WebBrowser2.Visible = False
CommandButton5.Visible = False
CommandButton6.Visible = False

I get object variable not set on the upper example! Im trying to get it to
search a range of items in a web page and return the first one with seven
characters (a post code ie 6 character and one space!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time error 91: Object Variable or With block variable not set Ayo Excel Programming 1 August 17th 09 11:29 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM
Pivot Table - Object variable or with block variable not set? George Nicholson[_2_] Excel Programming 1 April 16th 04 09:12 PM


All times are GMT +1. The time now is 04:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"