VBA Navigating through webpages

Emily30187

New Member
Joined
Jun 13, 2017
Messages
1
Hi,

I've gota macro that opens a webpage and logs me in to a portal. It then navigates to a new tab but am then stuck as I can't find the element name for the next button. I can debug.print the element names on the initial webpage but nothing further than that appears in my immediate window.

Here is my code so far:
Sub Log_In()
On Error GoTo Err_Clear
sURL = "MY WEBPAGE"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True


Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE
Set HTMLdoc = oBrowser.document
' ***INTIAL PAGE***
HTMLdoc.all.emailAddress.Value = "MY EMAIL ADDRESS"
HTMLdoc.all.Password.Value = "MY PASSWORD"
HTMLdoc.all.Login.Click
'***SECOND PAGE***
HTMLdoc.all.rEPORTS.Click
'***THIRD PAGE***
HTMLdoc.all.I NEED THIS.Click

For Each oHTML_Element In HTMLdoc.getElementsByTagName("submitButtonName")
Debug.Print oHTML_Element.Name
Next
Debug.Print TDelement.ID, TDelement.Value
Debug.Print oHTML_Element.Name
' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If

End Sub

Hope you can help
Em
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try waiting after each click and see if it helps. However, I would suggest that you check both the Busy and ReadyState properties, as follows...

Code:
With oBrowser
    Do While .Busy Or .ReadyState <> READYSTATE_COMPLETE
        DoEvents
    Loop
End With

Hope it helps!
 
Upvote 0

Forum statistics

Threads
1,215,950
Messages
6,127,906
Members
449,411
Latest member
AppellatePerson

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