Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2004, 10:07 AM
Registered User
 
Join Date: Jul 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I submit a webform from VB/VBA?

Preface: I am programming via the VBA code window of Excel 2002.
I've added Microsoft Internet controls and Microsoft HTML object library to the project references.

So far this works:

Dim web As WebBrowser
Private Sub FormLoad()
   Set web = New WebBrowser
   Set web = CreateObject("internetexplorer.application")
   web.Navigate2 "http://blahblahblah.com/"
   web.Visible = True
End Sub
Private Sub FillForm()
   web.Document.Forms(0).EMP__NO.Value = "111111"
   web.Document.Forms(0).PASSWORD.Value = "password"
End Sub

FormLoad launches IE to the appropriate web site.
FillForm fills in the 2 fields of the form.

I am stumped as to how to programmically hit the submit button. I tried adding the following line to the FillForm Sub with varying results.

web.Document.Forms(0).submit
VB is waiting for an invalid/missing method

web.Document.Forms(0).submit()
VB identifies this as a syntax error

web.Document.Forms(0).submit = True
VB states that there is an invalid method or empty value

The total program logs into a website, fills out a series of forms, generates an excel spreadsheet and pulls the data back into excel. These submit buttons are the only thing stopping the program from running.

I'll post the final code after everything is working.

Thanks in advance for any help
 
Old July 29th, 2004, 03:56 PM
Registered User
 
Join Date: Jul 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tbarthen
Default

I'm also about to try something like this - except that after I login, I want to upload a file. I'll try your code, and see if I have any luck with the website I'm connecting to. If I can get it to work, I'll let ya know. This is pretty new to me though, so I'll probably be waiting to find your solution before I have any luck.

Tom Barthen
 
Old July 29th, 2007, 04:03 AM
Registered User
 
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can try the click() method ...

as for web.document.forms(0).buttonName.click()

please inform me if it works. [email protected]
 
Old August 1st, 2007, 04:48 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Try using web.Document.Forms(0).submit() (not sure of the case.) This works within the javaScript on a webpage, so it should work in your VB.
 
Old August 9th, 2007, 04:42 AM
Authorized User
 
Join Date: Jul 2007
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to vksingh24
Default

Have u checked the form settings. Is there any METHOD("POST/GET") specified and ACTION value of the form.

If these values are not assigned then, It will give error.

or you can also add them into code before submit

web.Document.Forms(0).Action="<file _ name>"

web.Document.Forms(0).Method="GET/POST"

__________________
Vikash Kumar Singh





Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA, VB, VB.NET,...??? jumpjack Visual Basic 2005 Basics 2 September 24th, 2007 02:52 PM
How to submit the different data on single submit pushpa Classic ASP Databases 1 January 24th, 2007 07:10 PM
VB & VBA vin_0x1 Pro VB 6 0 April 7th, 2006 04:57 AM
How can we submit a form without a submit butto phpsharma BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 4 October 20th, 2003 08:50 AM
VBA v. VB mdbriggs Access VBA 2 August 22nd, 2003 10:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.