Automating consent page through excel VBA

kbafna

New Member
Joined
Sep 13, 2010
Messages
1
Hi,

I have created a web query to get a data from the web to my excel sheet. There are 2 data tables on this page.
The web query is as follows -

WEB
1
http://www.dtcc.com/products/derivserv/data_table_iii.php?id=3.22
Selection=dataTable
Formatting=None
PreFormattedTextToColumns=True
ConsecutiveDelimitersAsOne=True
SingleBlockTextImport=False
DisableDateRecognition=False
DisableRedirections=False


However when the user tried to refresh the data for the first time from his machine he is redirected to a consent page. This page have "I Agree"and "Decline" button. -
http://www.dtcc.com/products/consent.php?id=tiwd/products/derivserv/data_table_iii.php?id=3.22


I tried automating the clicking of I Agree button through VBA with the help of following code -

Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Sub Consent_To_DTCC()
Dim oHTML_Element As IHTMLElement
Dim sURL As String
On Error GoTo Err_Clear
sURL = "http://www.dtcc.com/products/consent.php?id=tiwd/products/derivserv/data_table_iii.php"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.navigate sURL
oBrowser.Visible = False
Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.document

For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
If oHTML_Element.Type = "submit" Then If oHTML_Element.getAttribute("value") = "I Agree" Then oHTML_Element.Click: Exit For
Next
' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
If Err <> 0 Then
Debug.Assert Err = 0
Err.Clear
Resume Next
End If
End Sub

However the automation is still throwing a Runtime error 1004 sating that web query did not return any data when it is run for the first time on user machine. After the user manually go and click on the I accept button on the consent page, the automation works fine.

Can you please advise how do it i automate the "I agree" consent on any php page.

Thanks
Kbafna
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top