[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Using VB to enter data on a Web Form

Posted on 2003-11-03
16
Medium Priority
?
536 Views
Last Modified: 2010-05-01
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
0
Comment
Question by:ajpelkey
[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
  • 4
  • 3
  • 3
  • +4
16 Comments
 
LVL 9

Assisted Solution

by:Dang123
Dang123 earned 500 total points
ID: 9673682
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9673979
www.angelfire.com/realm/vb-shared/index.html under ie topic (example for Hotmail)
0
 
LVL 16

Assisted Solution

by:Richie_Simonetti
Richie_Simonetti earned 500 total points
ID: 9674054
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Accepted Solution

by:
fantasy1001 earned 600 total points
ID: 9675615
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
 
LVL 15

Expert Comment

by:JackOfPH
ID: 9675723
Listening....

:-)
0
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9676048
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
 

Author Comment

by:ajpelkey
ID: 9676190
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
 
LVL 3

Assisted Solution

by:monvelasquez
monvelasquez earned 400 total points
ID: 9676327
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
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9676456
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
 

Author Comment

by:ajpelkey
ID: 9681053
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
 
LVL 9

Assisted Solution

by:Dang123
Dang123 earned 500 total points
ID: 9681181
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
 
LVL 16

Assisted Solution

by:Richie_Simonetti
Richie_Simonetti earned 500 total points
ID: 9681361
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
 

Author Comment

by:ajpelkey
ID: 9681654
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
 

Expert Comment

by:aftab2003
ID: 9683927
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
 

Expert Comment

by:aftab2003
ID: 9684086
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9686764
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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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