How to get macro load search into google? (1 Viewer)

Jonpolo

New member
Local time
Today, 11:35
Joined
Jul 28, 2009
Messages
3
I'm designing a database that needs to be able to have the functionality to be able to type a company name in one field and then have a button function to be able open google finance having searched for the company in the box.

e.g if i had entered Microsoft in the field the macro/function button should open the google finance page for Microsoft.... I then need the function button to work for any other company name typed in that field...

Any ideas?

Thanks in advance!
 

ajetrumpet

Banned
Local time
Today, 05:35
Joined
Jun 22, 2007
Messages
5,638
try this.....
 

Attachments

  • example.mdb
    140 KB · Views: 425

Jonpolo

New member
Local time
Today, 11:35
Joined
Jul 28, 2009
Messages
3
That is exactly what I wanted - thank you very very much!!!
 

Jonpolo

New member
Local time
Today, 11:35
Joined
Jul 28, 2009
Messages
3
Thanks

That worked great- is there a way of doing the same thing for other search engines? i wanted to have a button for google, reuters and any other similar site.

I tried replacing reuters.com with the google.com in your code but to no avail - i assume the code relates to the webpage in some way but my knowledge is limited at that!

Any ideas of how i can use your example on other sites too?

Thanks

Jon
 

Mike375

Registered User.
Local time
Today, 20:35
Joined
Aug 28, 2008
Messages
2,548
Here is variation

ie.Visible = True
ie.navigate "http://www.weatherby.com/" & ([Forms]![frm]![txt])
While ie.busy
DoEvents
Wend

Weatherby makes guns. If I type Products in the text box then it will open the site and then open products.

Another variation

ie.Visible = True
ie.navigate "http://www.google.com.au"
While ie.busy
DoEvents
Wend

Whatever I type in the text box is like typing in Google including surrounding with " " such as "Microsoft Access". The .au following Google is because of Australia.
 

ajetrumpet

Banned
Local time
Today, 05:35
Joined
Jun 22, 2007
Messages
5,638
Thanks

That worked great- is there a way of doing the same thing for other search engines? i wanted to have a button for google, reuters and any other similar site.

I tried replacing reuters.com with the google.com in your code but to no avail - i assume the code relates to the webpage in some way but my knowledge is limited at that!

Any ideas of how i can use your example on other sites too?

Thanks

Jon
Jon,

you need to know HTML to use this functionality in VISUAL BASIC. here is a quick tutorial on element id's...

this HTML code snippet is from your google finance page:
Code:
<form method=GET action="/finance" name=f>
<input name=q id=searchbox autocomplete=off size=40 maxlength=2048
             type=text tabindex=1 title="Quote search input"
             value="">
<input type=submit value="Get quotes" > 
as you can see, the search box ID is "q". Google is notorious for naming their search fields "q". apparently they do it all the time. at any rate though,. textboxes and buttons in HTML are usually types called inputs. these are element types. elements are similar entities in HTML like controls are in Access. as you can see from my sample i gave you, i am filling the search box with the text box value on the form. you can do this for any web page you want as long as you know the ID of the search box on the HTML page. if you use the getelementbyID method as i did in my sample, you always need to use the ID of the element which you are populating.

as for buttons, the method is a little different. i think in my sample, i submitted a form. you can automate searches by doing this, or by clicking the button. if a button has a name that is specified, you can use this HTML code in your VBA to simply click it:
Code:
ie.document.Forms(FORM INDEX NUMBER).Item(BUTTON NAME).Click
however, if it doesn't have a name, you have to submit the form that the button is inside of. do that this way:
Code:
ie.document.Forms(FORM INDEX NUMBER).submit
the process works either way.

just remember that the form index starts at 0 and goes from there. the first form input type that you encounter from the beginning of the HTML code is form 0, the next form 1, and so on. do that to get the index if there is no button name to click it.
 

DanHolland

Registered User.
Local time
Today, 03:35
Joined
Feb 6, 2013
Messages
19
Hi i was just looking at the sample that someone provided and was wondering if a similar thing was possible but clicking on a text box (for a postcode) will open up the postcode location in google maps?

Thanks in advance
 

Users who are viewing this thread

Top Bottom