Using VB to enter data on a Web Form

I have a website that I go to every morning to gather data.  I want to use Visual Basic to gather the data automatically but I first have to fill in a form of what data to extract (date, report, etc...)  Is there a code to automatically fill in a form automatically.  I was going to try a bunch of "SendKeys" but it seems to be the long way and it's not working.

HELP please.!!!

Thx, AJ
ajpelkeyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richie_SimonettiIT OperationsCommented:
www.angelfire.com/realm/vb-shared/index.html under ie topic (example for Hotmail)
0
Richie_SimonettiIT OperationsCommented:
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

fantasy1001Commented:
Ok, here is an example of filling the google form

    Set IE = CreateObject("InternetExplorer.Application")
    IE.Navigate "http://www.google.com"
    IE.Visible = True
    Do While IE.Busy
       DoEvents
    Loop

IE.Document.All("username").Value = "so hard"
IE.Document.All("password").Value = "visual basic"
Ie.DOcument.All("submit").Click   'this will click the button

Description:
First you open the ie object, then we can get to the control inside the form with ie.document.all("controlname").value/click

~ fantasy ~
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JackOfPHCommented:
Listening....

:-)
0
fantasy1001Commented:
Sorry, sorry, wrong syntax
Let assume the Google is the place where you upload. you can use this

Set IE = CreateObject("InternetExplorer.Application")
    IE.Navigate "http://www.google.com"
    IE.Visible = True
    Do While IE.Busy
       DoEvents
    Loop

IE.Document.All("q").Value = "so hard"
Ie.DOcument.All("btnG").Click   'this will click the button

Try to experience and find the q and btnG control name with FrontPage.

~ fantasy ~
0
ajpelkeyAuthor Commented:
ok, ALL the above answers helped me out a TON, but let's take it to the next level.  I have a list box that has about 20 items.  I want to select them all.  The list box is named "as_tks_projects".  The list box is set as follows: <SELECT NAME="as_tks_projects" SIZE="3"  multiple>

If I use the following command: IE.Document.All("as_tks_projects").Value = "BBC1" it selects the single item.

If I use the following command: IE.Document.All("as_tks_projects").click it selects the first item.

I want to know how to select all items.

Thx,
AJ
0
monvelasquezCommented:
Try this

Dim i as integer
For i = 0 to IE.Document.All("as_tks_projects").options.length-1
      IE.Document.All("as_tks_projects").options(i).selected = True
Next

____________
Raymond:\>_
0
fantasy1001Commented:
I think Raymond has give you the direction on doing that,
the .Value will return the object in select
the .Click is a method to click on the submit button

~ fantasy ~
0
ajpelkeyAuthor Commented:
ok, I am gonna share the wealth on this one because all the answers are awesome.  I need one more help.  The last website I am taken to is a place to download a file.  The file is a link.  The link is as follows: /web01/user_reports/AJP915??.psr where the question mark is a variable.  How can I identify the file, and open the file (or download but prefer just to open).
0
Dang123Commented:
This should help you identify the file

Public Function GetHTMLCode(URL As String)
Dim IE As Object
Dim i As Long

Set IE = CreateObject("InternetExplorer.Application")
  IE.Navigate URL
  While IE.Busy
      DoEvents
  Wend
  For i = 0 To IE.Document.All.length - 1
      If IE.Document.All(i).Tagname = "A" Then
          If InStr(IE.Document.All(i).href, ".psr") > 0 Then
            MsgBox IE.Document.All(i).href
          End If
      End If
  Next
End Function
0
Richie_SimonettiIT OperationsCommented:
just a little modification:

Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

'example by Matthew Gates (Puff0rz@hotmail.com)

Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then DownloadFile = True
End Function
Public Function GetHTMLCode(URL As String)
Dim IE As Object
Dim i As Long

Set IE = CreateObject("InternetExplorer.Application")
  IE.Navigate URL
  While IE.Busy
      DoEvents
  Wend
  For i = 0 To IE.Document.All.length - 1
      If IE.Document.All(i).Tagname = "A" Then
          If InStr(IE.Document.All(i).href, ".psr") > 0 Then
            DownloadFile IE.Document.All(i).href, "c:\mydownloadedfile.htm"

          End If
      End If
  Next
End Function
 
0
ajpelkeyAuthor Commented:
Everyone,
You did it.  You got me from start to finish on this code.  Big thx goes to fantasy1001 because he had me going in the right direction.  I ended up running into more roadblocks on the way and the thx go out to the rest of the Assisted Answers.

I have asked my boss if I can add you all to our payroll but unfortunately the economy hinders us.

Thx to all,
AJ
0
aftab2003Commented:
If I just want to click on a link that is on a web page conatining mamy links, how do I do that ?:

<a href="http://www.cnn.com/index.html">CNN</a>

I tried this:
For i = 0 To IE.document.All.length - 1
   If IE.document.All(i).tagName = "A" Then
     If InStr(IE.document.All(i).href, ".htm") > 0 Then
      'IE.document.All(i).href.Click ' this is the ???question :-) it does not work
      MsgBox IE.document.All(i).href
     End If
    End If
 Next


Thanks
Aftab
0
aftab2003Commented:
This works

For i = 0 To IE.document.All.length - 1
   If IE.document.All(i).tagName = "A" Then
     If InStr(IE.document.All(i).href, "cnn.com") > 0 Then
      'DownloadFile IE.document.All(i).href, "c:\mydownloadedfile.htm"
      'IE.document.All(i).href.Click
      MsgBox IE.document.All(i).href
      'MsgBox i
      IE.navigate IE.document.All(i).href
     End If
    End If
 Next

Aftab
0
Richie_SimonettiIT OperationsCommented:
If problem is links in a web page, there is a links collection that we can use to iterate throught all link on a given page.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.