PDA

View Full Version : VBA to click OK in Javascript popup box?



igotgame
05-05-2009, 09:18 AM
I am doing some data pulling from a website into Excel...I am automating this whole process, but this one button is causing me problems.

Here is the website code:

function exit(){
if (parent.DataFrame.document.mainForm.WP_FORM_SUBMITTED.value!="TRUE") {
if (confirm("You are now exiting Workout Prospector. Click OK to exit.\nClick CANCEL to return to the application."))
{
parent.DataFrame.document.mainForm.WP_EXIT.value="TRUE"
parent.DataFrame.document.mainForm.target="_top"
parent.DataFrame.document.mainForm.WP_FORM_SUBMITTED.value="TRUE"
parent.DataFrame.document.mainForm.submit()
}
}
}



and I am using the following so far:

On Error Resume Next
For i = 0 To .Document.frames.Length - 1
.Interactive = False
.DisplayAlerts = False
Call .Document.frames(i).execScript("exit()", "JavaScript")
.Document.forms(0).submit
If Err.Number = 0 Then

Exit For
End If
Next
On Error GoTo 0


This will make the pop box come up...but I don't know how to make it confirm "OK" without clicking it. In order for Excel to move on to the next file I need to box clicked "OK".

Can anyone help?

igotgame
05-06-2009, 07:09 AM
anyone?