PDA

View Full Version : event / error trapping?



HarrisLFC
03-13-2008, 12:32 PM
Hi, I'm trying to automate an account transaction using Internet Explorer. I've been partially successful based on the code that I've on this site.

I submit a set of notes using Internet Explorer:

' The account notes...
IE.Document.all("txtNotes1").Value = "Service Termination Notice"
IE.Document.all("txtNotes2").Value = "mailed 3/11/2008"
.
.
' submit the note...
IE.Document.all("submit1").Click

If the note is successfully submitted, Internet Explorer returns an OK / Cancel dialog box saying that the notes have been "successfully added."

If the note failed, Internet Explorer returns a regular web page, but with a SQL error. I'm guessing for this I will have to load the web page into VBA to do a find.

How would I trap for the OK / Cancel dialog box and click OK or Cancel (it's an ambiguous box) on it to loop to the next account (or load the error page for a find operation)?

Trevor
03-14-2008, 01:16 PM
dim responce as string

responce =msgbox("your msg here"), vbokcancel + vbinformation, "msgbox title"

if responce = vbok then [condition]
else: [condition[
end if
end sub

this just performa an action based on respoce to the question
you may also have a loop on condition
ie if respoce = vbok then then goto acnext record

HarrisLFC
03-14-2008, 03:20 PM
Thanks, but the msgbox is not generated by me. It's generated by the application through Internet Explorer.

After the Account Notes are submitted, I want to:

IF [OK/Cancel Dialog box saying that "notes have been added" THEN
click on OK box to proceed to next account
ELSE
[search web page for error message]
END IF

I think can do the ELSE part -- searching the web page for an error message, but:

How do I figure out that the application returned a dialog box through Internet Explorer that I have to click (in order to go on to the next account)? And how do I click on it, since there is no source code in the dialog box for me to tell me name of the button? (it's an ok button)

Trevor
03-14-2008, 04:51 PM
Then you will need to get the page source code for that page, to see what the code for that error message is, then in your code under tools references, you need to click the Intet explorer reference , and then go from there on how to handle that mesgbox responce,
I hope this helps, I thaught the messge was being generated by you not IE , so I took a shot at it.