Automate IE from VB - site with onclick = "return confirm('Update?')"

Hi,
I'm working on automating updating information on a web-site from VBA. The site use  "onclick = "return confirm('Update?')""  on the submit button.

Is there a way to "click" on the OK button on the alertbox?
Or somehow bypass the alertbox?

I'm using code like this:

    Set oIE = New SHDocVw.InternetExplorer
   oIE.Navigate "https://ddsmedlem.cbrain.dk/member.aspx?func=member.edit&mno=" & c.Value
   oIE.Document.all("Address1:_ctl0").Value = c.Offset(0, 3).Value
   oIE.Document.all("Address1:_ctl1").Value = c.Offset(0, 4).Value
   oIE.Document.all("submitButton").Focus
   oIE.Document.all("submitButton").Click

thor_ostergaardAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

AzraSoundCommented:
Do:

oIE.Document.all("formName").Submit


to bypass.

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
thor_ostergaardAuthor Commented:
Great - thanks
thor_ostergaardAuthor Commented:
Sorry - did'nt work - the information is not updated.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

thor_ostergaardAuthor Commented:
It is a .net site and the problem is properly a missing postback
AzraSoundCommented:
Is that the only javascript in the onclick of the submit button?  Clicking submit and directly submitting the form should have no change in the way the data is submitted.
thor_ostergaardAuthor Commented:
Nope - it is asp.net and there are a few more scripts
AzraSoundCommented:
It shouldn't matter what the server side language is...but if they coded the server side to specifically look for the button click, and not just the form submitted, then that will be a problem.

All I can think of is to trap for that event in your code, and try to automatically override the event handler with your own.  To do this, go to Project -> References and select HTML Object Library.  Then in your code module, place this at the top:

Private WithEvents btnSubmit As HTMLButtonElement (<~~ I think that is what it is called)

After navigating to the page, do:

Set btnSubmit = oIE.Document.all("submitButton")

You should be able to select, from your code module, the btnSubmit object in the top left dropdown box.  Once selected, you should see all the events in the right hand dropdown box (like any other control you place on a form, for example).  You should be able to select the onclick event.  Selecting it should give you something like:


Private Function btnSubmit_onclick() As Boolean

End Function


Inside that function, simply put:

btnSubmit_onclick = True


Then run your code as you had it before where it clicked the button to submit the form.
thor_ostergaardAuthor Commented:
It's not possible to declare the HTMLButtonElement with events :-(
AzraSoundCommented:
You must be writing your code in a standard .bas module.  It must be in a form or class module to utilize events of any kind.
thor_ostergaardAuthor Commented:
I'm running in a module now and the new eventhandler is called, but after the eventhandler on the site :-(
thor_ostergaardAuthor Commented:
Wow :-))))

btnSubmit.onclick = "" 

did the trix :-)

I'm running now. Thanks for your help.
AzraSoundCommented:
I guess that would make sense too...just delete the javascript code that executes when clicked.  Good job.
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.