?
Solved

Navigating Browser using Excel VBA 1.

Posted on 2014-11-02
12
Medium Priority
?
448 Views
Last Modified: 2014-11-07
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

0
Comment
Question by:canesbr
[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
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 46

Assisted Solution

by:aikimark
aikimark earned 400 total points
ID: 40418992
"st" is the name attribute, not the id attribute.
<input type="text" value="" name="st" maxlength="90" placeholder="Search Best Buy" id="gh-search-input" />

Open in new window


Your locating by id statement should probably be:
doc.GetElementByID("gh-search-input").Value = "bose"

Open in new window

0
 

Author Comment

by:canesbr
ID: 40419449
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
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40419510
Change the IE variable definition
Dim IE As Object

Open in new window

0
Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

 

Author Comment

by:canesbr
ID: 40420345
Did that. Still get error.
Regards
Brian
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40420444
what error?
0
 

Author Comment

by:canesbr
ID: 40420516
Error 438 "Object doesn't support this property or method"
GetElementByID
Regards
Brian
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40420538
What do these two statements do?
Doodly IE
Muddly IE

Open in new window

0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40420759
^Isn't it obvious? :-P
0
 

Author Comment

by:canesbr
ID: 40420774
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
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 1600 total points
ID: 40427104
I'm not sure what your end goal is but apart from aikimark's adjustment for finding the input field, you need something similar for the button, for a bit of a quick and dirty solution try:
doc.GetElementsByTagName("button")(0).Click

Open in new window


To get IntelliSense on your doc variable you need to declare it:
Dim doc As HTMLDocument

Open in new window

For this to work, your VBA project needs to reference "Microsoft HTML Object Library".

I attached a workbook with the adjusted code.
tst.xlsm
0
 

Author Comment

by:canesbr
ID: 40427727
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
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 40427868
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?
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

762 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