ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   submit web form (https://www.excelbanter.com/excel-programming/414476-submit-web-form.html)

geebee

submit web form
 
hi,

i have the following. i was able to fill the fields in, but i just cant get
the code to simulate clicking the "OK" button to submit the form...

'This project includes references to "Microsoft Internet Controls" and
'"Microsoft HTML Object Library"

'Variable declarations
Dim myIE As New InternetExplorer 'New '
Dim myURL As String
Dim myDoc As HTMLDocument
Dim strSearch As String

'Set starting URL and search string
myURL = "https://cantsay.com/Transactions/Logon.asp"
strSearch = "me"

'Make IE navigate to the URL and make browser visible
myIE.navigate myURL
myIE.Visible = True

'Wait for the page to load
Do While myIE.Busy Or myIE.readyState < READYSTATE_COMPLETE
DoEvents
Loop

'Set IE document into object
Set myDoc = myIE.document

'Enter search string on form


Dim strpassword As String
strpassword = "mine"

With myDoc.getElementsByName("UserName")(0)
..Value = strSearch
End With


With myDoc.getElementsByName("Password")(0)
..Value = strpassword
End With


With myDoc.getElementsByName("Client")(0)
..Value = "TEST"
End With


'Submit form
'myDoc.getElementsByName("Client")(0).OK.submit
'myDoc.forms(0).submit
'myDoc.forms("Logon").submit
'Set sform = myDoc.forms(0)
'sform.submit

'Set formbutton = myDoc.getElementsByName("btnSubmit")
'formbutton.Click

Windows.Application.SendKeys "{ENTER}"
SendKeys (strIn)
SendKeys "{ENTER}"

....

any help would great be appreciated!!!

thanks in advance,
geebee


Tim Williams

submit web form
 
Difficult to suggest what to try without seeing the HTML source of the page.

Tim

"geebee" (noSPAMs) wrote in message
...
hi,

i have the following. i was able to fill the fields in, but i just cant
get
the code to simulate clicking the "OK" button to submit the form...

'This project includes references to "Microsoft Internet Controls" and
'"Microsoft HTML Object Library"

'Variable declarations
Dim myIE As New InternetExplorer 'New '
Dim myURL As String
Dim myDoc As HTMLDocument
Dim strSearch As String

'Set starting URL and search string
myURL = "https://cantsay.com/Transactions/Logon.asp"
strSearch = "me"

'Make IE navigate to the URL and make browser visible
myIE.navigate myURL
myIE.Visible = True

'Wait for the page to load
Do While myIE.Busy Or myIE.readyState < READYSTATE_COMPLETE
DoEvents
Loop

'Set IE document into object
Set myDoc = myIE.document

'Enter search string on form


Dim strpassword As String
strpassword = "mine"

With myDoc.getElementsByName("UserName")(0)
.Value = strSearch
End With


With myDoc.getElementsByName("Password")(0)
.Value = strpassword
End With


With myDoc.getElementsByName("Client")(0)
.Value = "TEST"
End With


'Submit form
'myDoc.getElementsByName("Client")(0).OK.submit
'myDoc.forms(0).submit
'myDoc.forms("Logon").submit
'Set sform = myDoc.forms(0)
'sform.submit

'Set formbutton = myDoc.getElementsByName("btnSubmit")
'formbutton.Click

Windows.Application.SendKeys "{ENTER}"
SendKeys (strIn)
SendKeys "{ENTER}"

...

any help would great be appreciated!!!

thanks in advance,
geebee





All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com