GAURAV SEMWL
GAURAV SEMWL

Reputation: 27

How do I fix Run time error. Automation Error

hello everyone I am facing this issue anyone please help me to fix this issue. enter image description here

enter image description here

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

Upvotes: 0

Views: 502

Answers (1)

GAURAV SEMWL
GAURAV SEMWL

Reputation: 27

this problem is fixed after downgrade the window from Window 11 to Window 10.

Upvotes: 0

Related Questions