05-09-2008, 02:46 AM
How can I send text to another application through an Excel VBA sub routine, particularly Internet Explorer?
For example... press a button in excel to open internet explorer (new window) and goto www.google.com and type in "test" in the search field.
I was able to open the webpage with Shell ("iexplorer location" "website") but when i try using Sendkeys "text", it doesnt seem to work.
I also cant seem to figure out how to activate a specific IE window... if I have 2 IE windows open one is at google and the other is at yahoo... im not sure how to use an appactivate (or similar) to distinguish the two...
05-09-2008, 04:07 AM
First you should add referneces of Microsoft Internet Controls and Microsoft Html object Library.
If the brwoser is already open then you can run following code to activate google site.And manipulation of vba and html you should know html Dom(http://www.w3schools.com/HTMLDOM/default.asp) and webpage inspector to know html behind the google page.
Public IEs As SHDocVw.ShellWindows
Public IE As SHDocVw.InternetExplorer
Dim Doc As HTMLDocument
Set IE = New SHDocVw.InternetExplorer
Set IEs = New SHDocVw.ShellWindows
For Each IE In IEs
If IE.LocationURL = "http://google.com" Then
IE.Visible = True
Set IE = IE
05-09-2008, 04:37 AM
There is also a slight code variation found in the code library section of our Knowledge Base:
05-09-2008, 10:24 PM
Thanks, I was able to come up with a solution to solve this problem - it seems to
My work intranet has the following html code on their timesheet...
<OPTION value="1" selected>Log In</OPTION>
<OPTION value="9">Log Out</OPTION>
<OPTION value="10">System Aux</OPTION>
<OPTION value="12">New Hire Training</OPTION>
It seems easy enough to send text or a click a button from VBA to IE, but how would I go about selecting one of these options?
Without access from home, I am taking a stab at this ... I am curious if anyone knows if something like... objIE.Document.All("logtypechange").Value = "1" would work (just changing the # value to the log selected)
05-11-2008, 12:50 PM
Assuming that's a drop-down with fixed options, you do it the same way you'd pass a value to a text box, except you pass one of the acceptable values, e.g., .prov.value:
You just need to figure out the name of the control, which you didn't include in your post and proceed from there. ;)
You just need to figure out the name of the control, which you didn't include in your post and proceed from there.
just wondering.. do you know of any way or addon that would help distinguish these control names? I have a company page that's way too complicated for me to figure out what the names of each elements :mad: