GAURAV SEMWAL
New Member
- Joined
- Oct 19, 2022
- Messages
- 30
- Office Version
- 365
- Platform
- Windows
Hello everyone I am facing this problem to automatically download the file.
anyone please help me to fix this issue .
below is a code
Public Sub DownloadFile()
Dim objIE As InternetExplorer, currPage As HTMLDocument, url As String
Dim elements
url = "https://www.nseindia.com/companies-listing/corporate-filings-insider-trading"
Set objIE = New InternetExplorer
objIE.navigate url
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
Set currPage = objIE.document
objIE.Visible = True
'objIE.document.getElementById("CFinsidertrading-download").Click
Set elements = objIE.document.getElementsByClassName("dayslisting")
For Each element In elements 'loop through all <a></a> elements...
Set Links = element.getElementsByTagName("a")
For Each link In Links
If link.innerHTML = "3M" Then
link.Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
GoTo lbl3m
End If
Next link
Next element
lbl3m:
objIE.document.getElementById("CFinsidertrading-download").Click
Application.Wait Now + TimeSerial(0, 0, 40) 'alter to give enough time for window
Application.SendKeys "%{S}"
'Application.Wait Now + TimeSerial(0, 0, 20) 'alter to give enough time for window
'MsgBox "File downloaded"
End Sub
Thank you.
anyone please help me to fix this issue .
below is a code
Public Sub DownloadFile()
Dim objIE As InternetExplorer, currPage As HTMLDocument, url As String
Dim elements
url = "https://www.nseindia.com/companies-listing/corporate-filings-insider-trading"
Set objIE = New InternetExplorer
objIE.navigate url
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
Set currPage = objIE.document
objIE.Visible = True
'objIE.document.getElementById("CFinsidertrading-download").Click
Set elements = objIE.document.getElementsByClassName("dayslisting")
For Each element In elements 'loop through all <a></a> elements...
Set Links = element.getElementsByTagName("a")
For Each link In Links
If link.innerHTML = "3M" Then
link.Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
GoTo lbl3m
End If
Next link
Next element
lbl3m:
objIE.document.getElementById("CFinsidertrading-download").Click
Application.Wait Now + TimeSerial(0, 0, 40) 'alter to give enough time for window
Application.SendKeys "%{S}"
'Application.Wait Now + TimeSerial(0, 0, 20) 'alter to give enough time for window
'MsgBox "File downloaded"
End Sub
Thank you.