Link to home
Start Free TrialLog in
Avatar of Wayne Barron
Wayne BarronFlag for United States of America

asked on

TWebBrowser and Submit.Form issue?

Hello All;

 I am using the following code to click the [Submit] button on my site.
VIA the TWebBrowser ( TEmbeddedWB).  This works great, except it has a problem?
After it click the [Submit] Button, and the next page opens, I get an
Exception. It is trying to [Submit] the page again.

  I have used this code before, and have never had this problem before.
And now ?? I do not know ??

Provided is the Code that I am using.
Below the Code will be the " Exception " that I received on the next page.

==+==+==+==+==+==+==++=+==+==+=++=+==+==+==
add to [Uses :  MSHTML_TLB; ]

procedure TProject1.AdminWebDocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var
  AdminSubmit : IHTMLInputElement;
  MyDocument : IHTMLDocument3;
begin
   MyDocument := AdminWeb.Document as IHTMLDocument3;
   if Assigned(MyDocument) then
   begin
   AdminSubmit := (MyDocument.getElementsByName('Admin_Login').item(0,'')as
IHTMLInputElement);
   AdminSubmit.Form.Submit;
end; end;
==+==+==+==+==+==+==++=+==+==+=++=+==+==+==

Exception

---------------------------
Debugger Exception Notification
---------------------------
Project Project.exe raised exception class EAccessViolation with message
'Access violation at address 00483C79 in module 'Project.exe'. Read of
address 00000000'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help
---------------------------

It lands on
==+==+==+==+==+==+==
AdminSubmit.Form.Submit;
==+==+==+==+==+==+==

Any idea's on how to make this code work to where it only executes
When the " Username & Password " form is presented?
And not on pages that do not require it?

Thank you all in advance.
Carrzkiss
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Wayne Barron

ASKER

Thank you so very much [Geobul];

Adding the
is assigned(AdminSubmit) then

right before -  AdminSubmit.Form.Submit;

Did the trick.

Once again, thank you very much.

Carrzkiss
Avatar of geobul
geobul

The pleasure was mine :-)