sreekhosh
Member
Hi All,
I am trying to export and excel report from a website. Website is opening with the report but i am receiving a run-time error '2147467259 (80004005)':
Method Document of object 'IWebBrower2' failed.
I am using Internet Explorer 9
Here is my code.
I am trying to export and excel report from a website. Website is opening with the report but i am receiving a run-time error '2147467259 (80004005)':
Method Document of object 'IWebBrower2' failed.
I am using Internet Explorer 9
Here is my code.
Code:
Dim ipf, ie As Object
Dim path As String, savpath As String, scrap As String
Dim mybook As Workbook
Dim i As Integer, k As Integer
Dim ipath, initialpath As String
k = WorksheetFunction.CountA(Sheets("Control").Range("A9:A65000"))
For i = 9 To k + 8
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = False
Rval = Sheets("Control").Range("A" & i).Value
Rnme = Sheets("Control").Range("C" & i).Value
path = "https://xxxxxxxx.net/"
savepath = Sheets("Control").Range("B7").Value
ie.Navigate path
Do While ie.Busy
DoEvents
Loop
'Do While ie.readystate <> 4 Or _
' ie.Busy = True
' DoEvents
'Loop
Set ipf = ie.Document.all.Item("ButtonOK")
'ie.Document.all(106).Click
ipf.Click
Do While ie.Busy = True
DoEvents
Loop
GoTo Line01
Line0:
Application.Wait (Now + TimeValue("0:00:15"))
Line01:
If Not CheckFile("ReportsExcel.aspx") Then GoTo Line0
Windows("ReportsExcel.Aspx").Activate
ActiveWorkbook.SaveAs Filename:=savepath & "/" & Rnme & ".xlsx", FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
ie.Quit
Next
Set ie = Nothing
y = MsgBox("Download complete", vbOKOnly + vbInformation, "Alert")
End Sub