Run-time error -2147023170 (800706be): Automation error, the remote procedure call failed

I am getting this above-mentioned error on running. The purpose of this code is to take values from excel sheet and put two values from sheet into website then extract results from web in a sheet.
here is the code.
it shows error on this line Do While ie.Busy Or ie.readyState <> 4
i also used READYSTATE_COMPLETE it did not work too.
Sub WebAutomation()

Dim ie As Object
Dim html As Object
Dim inputFilePath As String
Dim wb As Workbook
Dim ws As Worksheet
Dim resultSheet As Worksheet
Dim lastRow As Long
Dim number1 As String
Dim number2 As String
Dim additionResult As String
Dim subtractionResult As String
Dim multiplicationResult As String
Dim divisionResult As String
Dim i As Long
Dim startTime As Single

' Define the input file path and open the workbook
inputFilePath = "C:Usersss483532OneDrive - GSKDocumentsCalculator.xlsx" ' Change this path to your actual file path
Set wb = Workbooks.Open(inputFilePath)
Set ws = wb.Sheets("Sheet1")

' Create a new sheet for results
On Error Resume Next
Application.DisplayAlerts = False
wb.Sheets("Results").Delete
Application.DisplayAlerts = True
On Error GoTo 0
Set resultSheet = wb.Sheets.Add
resultSheet.Name = "Results"
resultSheet.Range("A1:F1").Value = Array("Number 1", "Number 2", "Addition", "Subtraction", "Multiplication", "Division")

' Initialize IE
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.FullScreen = True ' Maximize the browser window

' Get the last row of data
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row

' Loop through each row of the input data
For i = 2 To lastRow ' Assuming the first row is headers
    number1 = ws.Cells(i, 1).Value
    number2 = ws.Cells(i, 2).Value
    
    ' Navigate to the web page
    ie.Navigate "https://www.automationandagile.com/p/demo-page.html"
    
    ' Wait for the page to load
    Do While ie.Busy Or ie.readyState <> 4
        DoEvents
    Loop
    
    ' Wait for the input element to be available
    startTime = Timer
    Do While Timer - startTime < 10
        On Error Resume Next
        Set html = ie.document
        If Not html Is Nothing Then
            If Not html.getElementById("num1") Is Nothing Then Exit Do
        End If
        On Error GoTo 0
        DoEvents
    Loop
    
    If html Is Nothing Or html.getElementById("num1") Is Nothing Then
        MsgBox "Failed to load the webpage or find the input elements.", vbCritical
        Exit Sub
    End If
    
    ' Fill the form and submit
    html.getElementById("num1").Value = number1
    html.getElementById("num2").Value = number2
    html.getElementById("btnCalculate").Click
    Application.Wait Now + TimeValue("00:00:02") ' Wait for results to load
    
    ' Retrieve results
    On Error Resume Next
    additionResult = html.getElementById("lblAdd").innerText
    subtractionResult = html.getElementById("lblSub").innerText
    multiplicationResult = html.getElementById("lblMult").innerText
    divisionResult = html.getElementById("lblDiv").innerText
    On Error GoTo 0
    
    ' Store the results in the results sheet
    resultSheet.Cells(i, 1).Value = number1
    resultSheet.Cells(i, 2).Value = number2
    resultSheet.Cells(i, 3).Value = additionResult
    resultSheet.Cells(i, 4).Value = subtractionResult
    resultSheet.Cells(i, 5).Value = multiplicationResult
    resultSheet.Cells(i, 6).Value = divisionResult
Next i

' Close IE
ie.Quit

' Save the workbook with results
wb.SaveAs Filename:=Left(inputFilePath, InStrRev(inputFilePath, ".") - 1) & "_results.xlsx", FileFormat:=xlOpenXMLWorkbook
wb.Close

MsgBox "Data extraction and calculation completed!", vbInformation

End Sub

New contributor

Saif Saeed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật