Hi,
Please help me as i am stuck at one point where i want my code to open another link after opening the first one.
my code works well till the first link is opened for the second one it does not work.
pls suggest me what to do.
Sub GoToWebSiteAndPlayAround()
Dim appIE As Object ' InternetExplorer.Application
Dim sURL As String
Dim UserN As Object ' MSHTML.IHTMLElement
Dim PW As Object ' MSHTML.IHTMLElement
Dim Element As Object ' HTMLButtonElement
Dim btnInput As Object ' MSHTML.HTMLInputElement
Dim ElementCol As Object ' MSHTML.IHTMLElementCollection
Dim ElementCol2 As Object ' MSHTML.IHTMLElementCollection
Dim Link As Object ' MSHTML.HTMLAnchorElement
Dim strCountBody As String
Dim lStartPos As Long
Dim lEndPos As Long
Dim TextIWant As String
Dim fdate As String
fdate = Sheet1.Cells("2", "H")
Application.ScreenUpdating = False
Set appIE = CreateObject("InternetExplorer.Application")
sURL = "https://downloads.theice.com/Settlement_Reports/"
With appIE
.navigate sURL
' uncomment the line below if you want to watch the code execute, or for debugging
.Visible = True
End With
'loop until the page finishes loading
Do While appIE.Busy
DoEvents
Loop
' click a text link on the page after that
Set ElementCol = appIE.document.getElementsByTagName("a")
For Each Link In ElementCol
If Link.innerHTML = "Gas/" Then
Link.Click
Exit For
End If
Next Link
Set ElementCol2 = appIE.document.getElementsByTagName("a")
For Each Link In ElementCol2
If Link.innerHTML = "ngxcleared_gas_" & fdate Then
Link.Click
MsgBox ("done")
Exit For
MsgBox ("Not done")
End If
Next Link
' loop until the page finishes loading
Do While appIE.Busy
DoEvents
Loop
End Sub
Bookmarks