How can I programmatically click on an image button to submit a form
Hi Experts,
I am using the IE web browser object in a MS Access form to automatically log into my online telephone account, although I am having a problem submitting the form. I am using the following visual basic code:
WebBrowserCallagenix.navigate "http://www.callagenix.com/"
DoEvents: DoEvents: DoEvents
Do While WebBrowserCallagenix.Busy 'wait until the page loads by looping
DoEvents
Loop
Set doc = WebBrowserCallagenix.Document 'access the document properties
DoEvents
Do While WebBrowserCallagenix.Busy
DoEvents
Loop
returnValue = FillForm("pAccountCode", "my_account", False)
returnValue = FillForm("pPassword", "my_password", False)
WebBrowserCallagenix.Document.Forms("cgxlogin").submit
The above code enters the account name and password into the appropriate fields but I then receive the following error message:
'Object doesn't support this property or method'
I think the issue is to do with the fact that the form uses the post method and/or an image for the login button, but this doesn't help me figure out how to submit the form.
Hi Mike, thank you for your comment. I should have made it clear that the form is on a third party website (www.callagenix.com) so I cannot alter the source html. The code for the form used is provided in the original question posted and this I cannot change. What I need to know is how can I submit it by interacting with the Microsoft browser's DOM.
Any thoughts?
paisleym
Hi
I programmed a solution to this in php, and basically what you have to do is to call the click event of the button name, i.e. loop through all the elements to get the button's name.
Hi Paisleym, I have tried the following:
WebBrowserCallagenix.Document.Forms("cgxlogin").elements("imageField").Click
but as it is not a button and is instead an image I get the following error message.
'Object variable or With block variable not set'
Clicking on the image in the browser control does submit the form though.