Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

HTML

Posted on 2003-03-08
11
Medium Priority
?
180 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
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

580 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