PC Review


Reply
Thread Tools Rate Thread

Automate Data Entry from .xls to IE

 
 
AB
Guest
Posts: n/a
 
      21st Jan 2008
I was hoping someone could explain in simple terms how i can make it
work, i.e., how do i write this code.

This is what I'd need:
I need to automate entering data into an IE based form. I got that far
to create IE object and to navigate to the url but i:
1. don't know how to get IE element name;
2. post value to that element;
3. make the code click on the element.

This is the unfinished code.

Sub WebLink()

Dim ie As Object
Dim sURL As String
Set ie = CreateObject("InternetExplorer.Application")

sURL = "http://www.yahoo.com"

ie.Visible = True
ie.Navigate sURL

'wait for response
Do Until Not ie.Busy And ie.ReadyState = 4
DoEvents
Loop

'Here i need a code to:
' 1. enter a value "Australia" in the search box
' 2. Click on "Web Search".

Set ie = Nothing

End Sub

Any help would be extremely helpful as i know something about the VBA
but this is outside my comfort zone. I have, however, achieved the
same result with SendKey - but i wanted to solve it in a bit more
robust way.

Thanks in advance!
 
Reply With Quote
 
 
 
 
JP
Guest
Posts: n/a
 
      21st Jan 2008
How about

sURL = "http://search.yahoo.com/search?p=Australia&fr=yfp-
t-501&toggle=1&cop=mss&ei=UTF-8"


HTH,
JP

On Jan 21, 10:54*am, AB <austris.bahanovs...@gmail.com> wrote:
> I was hoping someone could explain in simple terms how i can make it
> work, i.e., how do i write this code.
>
> This is what I'd need:
> I need to automate entering data into an IE based form. I got that far
> to create IE object and to navigate to the url but i:
> 1. don't know how to get IE element name;
> 2. post value to that element;
> 3. make the code click on the element.
>
> This is the unfinished code.
>
> Sub WebLink()
>
> Dim ie As Object
> Dim sURL As String
> * * Set ie = CreateObject("InternetExplorer.Application")
>
> * * * * sURL = "http://www.yahoo.com"
>
> * * * * ie.Visible = True
> * * * * ie.Navigate sURL
>
> * * * * 'wait for response
> * * * * Do Until Not ie.Busy And ie.ReadyState = 4
> * * * * * * * DoEvents
> * * * * Loop
>
> 'Here i need a code to:
> ' 1. enter a value "Australia" in the search box
> ' 2. Click on "Web Search".
>
> * * Set ie = Nothing
>
> End Sub
>
> Any help would be extremely helpful as i know something about the VBA
> but this is outside my comfort zone. I have, however, achieved the
> same result with SendKey - but i wanted to solve it in a bit more
> robust way.
>
> Thanks in advance!


 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      21st Jan 2008
Sorry, that didn't wrap properly.

Just go to Yahoo, put "Australia" in the search box and click
"Search", then copy the resulting URL and use it as the variable.
Yahoo puts the search term in the URL so it's simple to automate going
to their website.

For example:

Dim AskMe as String
AskMe = Inputbox("What would you like to search for?")

sURL = "http://search.yahoo.com/search?p=" & AskMe & _
"&fr=yfp-t-501&toggle=1&cop=mss&ei=UTF-8"

If you wanted the same thing from Google it would be:

sURL = "http://www.google.com/search?hl=en&q=Australia"

HTH,
JP

On Jan 21, 11:31*am, JP <jp2...@earthlink.net> wrote:
> How about
>
> sURL = "http://search.yahoo.com/search?p=Australia&fr=yfp-
> t-501&toggle=1&cop=mss&ei=UTF-8"
>
> HTH,
> JP
>

 
Reply With Quote
 
AB
Guest
Posts: n/a
 
      21st Jan 2008
Thanks for the promt answer. I'm afraid it might not do what i'd need
- I must admit, i had provided a bad example.
This is what i'm after - i'd hawe more complext website than just a
search engine - i'd have something like travel site (for example):
http://www.ryanair.com/site/EN/
then, i'd want the code to click on "Find Lowest rates";
then the code would select London>Dublin>23 Feb etc, and then the code
would "submit" the request, enter some data into blank text boxes in
the resulting page and so forth.
So, to enable me to do that i'd need to understand how i can get an
Element Name on a specific web site (if it's possible at all) and how
to "click on buttons" on web sites etc.

I need this as i need to enter (key in) data into a web based
Enterpise form and i need to automate that process (as all of the data
are in .xls - so, i just need to post them over to the web. As I said,
i've done that with SendKey but need to improve it with a better code
(like controling the object from within .xls rather than just sending
"tab" and "enter" and "F6" etc.)

Any idieas?
 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      21st Jan 2008
Good luck with that!

I suggest viewing the source code for the webpage (View>Source from
the IE toolbar) and noting the names of the inputboxes. You should try
searching "automate internet explorer" or "MSHTML automation" for code
samples. Here's a good one I found: http://www.xtremevbtalk.com/archive/.../t-175668.html

As always, I recommend you fill out the form manually and view the URL
to see if your search terms are embedded. If so, you can simply use
the URL as a string to pass it to the IE instance you created (see my
previous post).

Sorry I couldn't be more help here.

--JP

On Jan 21, 12:15*pm, AB <austris.bahanovs...@gmail.com> wrote:
> Thanks for the promt answer. I'm afraid it might not do what i'd need
> - I must admit, i had provided a bad example.
> This is what i'm after - i'd hawe more complext website than just a
> search engine - i'd have something like travel site (for example):http://www.ryanair.com/site/EN/
> then, i'd want the code to click on "Find Lowest rates";
> then the code would select London>Dublin>23 Feb etc, and then the code
> would "submit" the request, enter some data into blank text boxes in
> the resulting page and so forth.
> So, to enable me to do that i'd need to understand how i can get an
> Element Name on a specific web site (if it's possible at all) and how
> to "click on buttons" on web sites etc.
>
> I need this as i need to enter (key in) data into a web based
> Enterpise form and i need to automate that process (as all of the data
> are in .xls - so, i just need to post them over to the web. As I said,
> i've done that with SendKey but need to improve it with a better code
> (like controling the object from within .xls rather than just sending
> "tab" and "enter" and "F6" etc.)
>
> Any idieas?


 
Reply With Quote
 
Tim Williams
Guest
Posts: n/a
 
      22nd Jan 2008
Form elements typically are within a named form and themseleves have a
"name" attribute: they may also have an "id" attribute.

To access a "name"d input you can use:
ie.document.formname.elementname.value="myvalue"

If it has an id then:
ie.document.getElementById("theId").value="myvalue"

To submit a form:

ie.document.formname.submit
or
ie.document.forms(0).submit

If you want to investigate what the names or id's for various elements on a
page are then try this:
http://slayeroffice.com/tools/modi/v2.0/modi_help.html

Tim



"AB" <(E-Mail Removed)> wrote in message
news:43a41ed4-a5d0-4bcc-825f-(E-Mail Removed)...
>I was hoping someone could explain in simple terms how i can make it
> work, i.e., how do i write this code.
>
> This is what I'd need:
> I need to automate entering data into an IE based form. I got that far
> to create IE object and to navigate to the url but i:
> 1. don't know how to get IE element name;
> 2. post value to that element;
> 3. make the code click on the element.
>
> This is the unfinished code.
>
> Sub WebLink()
>
> Dim ie As Object
> Dim sURL As String
> Set ie = CreateObject("InternetExplorer.Application")
>
> sURL = "http://www.yahoo.com"
>
> ie.Visible = True
> ie.Navigate sURL
>
> 'wait for response
> Do Until Not ie.Busy And ie.ReadyState = 4
> DoEvents
> Loop
>
> 'Here i need a code to:
> ' 1. enter a value "Australia" in the search box
> ' 2. Click on "Web Search".
>
> Set ie = Nothing
>
> End Sub
>
> Any help would be extremely helpful as i know something about the VBA
> but this is outside my comfort zone. I have, however, achieved the
> same result with SendKey - but i wanted to solve it in a bit more
> robust way.
>
> Thanks in advance!



 
Reply With Quote
 
AB
Guest
Posts: n/a
 
      23rd Jan 2008
Thanks JP and Tim!

That was exactly what i needed - hints for the directions for me to go
to/to search. The links/advises look really promissing!
That should let me either do the trick or at least get started!

Thanks again!
 
Reply With Quote
 
JP
Guest
Posts: n/a
 
      23rd Jan 2008
You are welcome!


--JP

On Jan 23, 3:45*am, AB <austris.bahanovs...@gmail.com> wrote:
> Thanks JP and Tim!
>
> That was exactly what i needed - hints for the directions for me to go
> to/to search. The links/advises look really promissing!
> That should let me either do the trick or at least get started!
>
> Thanks again!


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automate Data-entry in IE application Venkatesh V Microsoft Excel Programming 2 12th Mar 2009 01:07 PM
automate data entry on Excel? Pepe Microsoft Excel Misc 1 30th Apr 2008 12:00 AM
Trying to automate data entry in word =?Utf-8?B?cGllcnNvbmFs?= Microsoft Word Document Management 9 21st Jun 2007 04:44 PM
Automate data entry =?Utf-8?B?Q2hp?= Microsoft Access 5 21st Jul 2006 05:14 PM
Automate data entry from sources James Pang Microsoft Access External Data 2 29th Dec 2003 08:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:56 AM.