PDA

View Full Version : Macro is getting Runtime error 91 - why?



musicgold
09-28-2012, 09:33 AM
Hi,

I am not sure why but I am getting a runtime error 91 at the red line in the following code.



For Each oCell In Selection
Filler = Trim(oCell.Value)

If Filler <> "" Then
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = 1
IE.navigate "http://maps.google.com/"
Do While IE.Busy: DoEvents: Loop

Set htmlDoc = IE.document

htmlDoc.getElementById("gbqfq").Value = Filler
htmlDoc.getElementById("gbqfb").Click


End If

Next



Thanks,

MG.

Simon Lloyd
09-28-2012, 11:03 PM
Have you checked to see what the actual value of "Filler" is? try adding msgbox "Trimmed oCell Value is: " & Trim(oCell.Value) & vblf _
& "Filler value is: " & Filler & vblf _
& "html doc value is: " & htmlDoc.getElementById("gbqfq").Value just below Set htmldoc = IE.Document and see what the values are.

musicgold
09-29-2012, 07:15 AM
Thanks Simon,

I tried that. The values in oCell and Filler are the same. The third value is "".

Simon Lloyd
09-29-2012, 07:34 AM
Well there's your issue the element you're getting is either wrong or is indeed showing a blank value or did you mean to do this, replacehtmlDoc.getElementById("gbqfq").Value = Filler
htmlDoc.getElementById("gbqfb").Click forhtmlDoc.getElementById(Filler).Click , don't forget to declare Filler as string!