Link to home
Start Free TrialLog in
Avatar of canesbr
canesbr

asked on

Navigating Browser using Excel VBA 1.

Excel 2007
Reference Microsoft Internet Controls
Trying to enter into a webpage a textbox
I get Error 438 "Object doesn't support this property or method"
in line  9  doc.GetElementByID("st").Value = "bose"
Please advise
Regards
Brian

Sub lime()
    Dim IE As SHDocVw.InternetExplorer
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate ("http://www.bestbuy.com")
    Doodly IE
    Muddly IE
    Set doc = IE.document
    doc.GetElementByID("st").Value = "bose"
    doc.GetElementByID("sb").Click
End Sub
Sub Doodly(IE)
    Do
        DoEvents
    Loop Until IE.readystate = 4
End Sub
Sub Muddly(IE)
    Do While IE.busy
        DoEvents
    Loop
End Sub

Open in new window

SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of canesbr
canesbr

ASKER

Hi @aikimark
I still get the same Error 438
I notice that Document.getelementbyid does not resolve to Document.GetElementByID
So maybe something else is not set properly?
Regards
Brian
Change the IE variable definition
Dim IE As Object

Open in new window

Avatar of canesbr

ASKER

Did that. Still get error.
Regards
Brian
what error?
Avatar of canesbr

ASKER

Error 438 "Object doesn't support this property or method"
GetElementByID
Regards
Brian
What do these two statements do?
Doodly IE
Muddly IE

Open in new window

^Isn't it obvious? :-P
Avatar of canesbr

ASKER

Posted in initial question.
They just are two different ways to wait for readiness
Sub Doodly(IE)
    Do
        DoEvents
    Loop Until IE.readystate = 4
End Sub
Sub Muddly(IE)
    Do While IE.busy
        DoEvents
    Loop
End Sub

Open in new window

Reminiscent of Kurt Vonnegut's
"We do doodly do what we must muddly must til we bust bodily bust"
Original:
We do, doodley do, doodley do, doodely do,
What we must, muddily must, muddily must, muddily must;
Muddily do, muddily do, muddily do, muddily do,
Until we bust, bodily bust, bodily bust, bodily bust.
Regardely Regards
Brian
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of canesbr

ASKER

Hi Robert
I have references to "Microsoft HTML Object Library" and to "Microsoft Internet Controls"
I ran Sub lime in your attachment
I get runtime error 13 Type mismatch on statement "Set doc = IE.document"
<sigh>
Please advise
Regards
Brian
Ah yes I get the same error now, the first time I run it, because a language choice page is displayed. When I choose a language and check 'remember' then the second time it works so I guess we need to 'defeat' that page, can you confirm that works the same for you?