?
Solved

HTML

Posted on 2003-03-08
11
Medium Priority
?
178 Views
Last Modified: 2010-04-07
Hello,

Does anybody knows how to let A VB programm fill in text boxes that are in a web page?

so that when i let my programm open www.google.com and i have a textbox in my programm and when i fill some stuff in the textbox my programm pasts the text from the textbox in the textbox from google

Greets Erik
0
Comment
Question by:WarLord
[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
11 Comments
 
LVL 3

Expert Comment

by:DocM
ID: 8093984
Here is an example with Hotmail.

'Make a reference to Microsoft Internet Controls
Dim WithEvents IE As InternetExplorer
Private Sub Form_Load()
Set IE = New InternetExplorer
With IE
     .navigate "www.hotmail.com"
     .Visible = True
End With
End Sub
 
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
 
If (pDisp Is IE) Then
    If InStr(1, URL, "passport.com/cgi-bin/login", vbTextCompare) Then
            Dim inp As Object
            Set inp = IE.document.All.Item("login")
            inp.Value = "username"  'replace with your id
           
            Set inp = IE.document.All.Item("passwd")
            inp.Value = "password"  'replace with your password
           
            Set inp = IE.document.All.Item("enter")
            inp.Click
     End If
End If
End Sub
 
0
 

Author Comment

by:WarLord
ID: 8094059
ok but what about when i don't want it to open in an external internet explorer like it happens here
0
 
LVL 2

Expert Comment

by:spauljoseph
ID: 8094150
Use WebBrowser control in your Form and pass the same arguments stated above into your WebBrowser control
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:WarLord
ID: 8094225
can anyone help me with this?

when i try this

Dim WithEvents IE As InternetExplorer
Private Sub Command1_Click()
Set IE = New InternetExplorer
With IE
    .Navigate "www.google.com"
    .Visible = True
End With
End Sub
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
           Dim inp As Object
                         
           Set inp = IE.Document.All.Item("q")
           inp.Value = "Test"
           
           Set inp = IE.Document.All.Item("btng")
           inp.Click
             
   
End Sub


it does everything it should do... fill in test at the textbox in the google form press the submit button etc

but when it's loaded it gives an error 438 object doesn't support this property... i think because the program reloads the page every time ( why? ) and in the second form of google the search field isn't called Q  

0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 80 total points
ID: 8094385
it appears that nobody copies the code in right way.
before paste the values in text box you should need to know if it is the correct url. So,

Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
if (pdisp is IE) then
   if instr(1,url,"what you need goes here", vbtextcompare) then
          Dim inp As Object
                         
          Set inp = IE.Document.All.Item("q")
          inp.Value = "Test"
         
          Set inp = IE.Document.All.Item("btng")
          inp.Click
   end if
end if
   
End Sub

Doing so, you assure that the code runs ONLY at desired url.
Cheers
PS: For complete code, take a look at www.angelfire.com/realm/vb-shared/index.html

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8094390
or:

if (pdisp is IE) then
  if instr(1,url,"what you need goes here", vbtextcompare) then
         IE.Document.All.Item("q").Value = "Test"
         IE.Document.All.Item("btng").Click
  end if
end if
 
End Sub

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8094392
or (faster):
Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)

if (pdisp is IE) then
 if instr(1,url,"what you need goes here", vbtextcompare) then
        with IE.Document.All
             .Item("q").Value = "Test"
             .Item("btng").Click
        end with
 end if
end if
 
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8094405
Optionally, you could use Google API stuff.
http://www.google.com/apis/
0
 

Author Comment

by:WarLord
ID: 8097120
Ok this stuff works all GREAT just what i needed, one more thing remaining... let's say i have a page my programm fills some stuff presses a button then it goes to the next page... how can i let my programm fill in stuff on the next page?
0
 

Author Comment

by:WarLord
ID: 8097387
not only this answer but the rest of your asnwers are also very helpfull
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8097721
Checking the url is the basic way:

if instr(1,URL,"Partial_and_unique_string_of_target_url_goes_here",vbtextcompare) then
    'do something
end if

if instr(1,URL,"Partial_and_unique_string_of_next_target_url_goes_here",vbtextcompare) then
    'do something more
end if

and so on...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 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