HTML

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
WarLordAsked:
Who is Participating?
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.

DocMCommented:
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
WarLordAuthor Commented:
ok but what about when i don't want it to open in an external internet explorer like it happens here
0
spauljosephCommented:
Use WebBrowser control in your Form and pass the same arguments stated above into your WebBrowser control
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

WarLordAuthor Commented:
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
Richie_SimonettiIT OperationsCommented:
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

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
Richie_SimonettiIT OperationsCommented:
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
Richie_SimonettiIT OperationsCommented:
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
Richie_SimonettiIT OperationsCommented:
Optionally, you could use Google API stuff.
http://www.google.com/apis/
0
WarLordAuthor Commented:
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
WarLordAuthor Commented:
not only this answer but the rest of your asnwers are also very helpfull
0
Richie_SimonettiIT OperationsCommented:
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
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.