PDA

View Full Version : From IE to Excel



clif
02-05-2021, 10:14 PM
What is the problems? Originally work well with below code





Application.ScreenUpdating = False

Dim objIe As Object, xobj As HTMLDivElement
'Set objIe = CreateObject("InternetExplorer.Application")
Set objIe = New InternetExplorerMedium

objIe.Visible = True



Dim id As Long
Dim Lastrow2 As Long

Sheets("main").Select
With ActiveSheet
Lastrow2 = .Cells(.Rows.Count, "A").End(xlUp).Row

For id = 2 To Lastrow2

objIe.navigate "http://abc.com/id=" & Sheets("main").Cells(custid, 10).Value

' While (objIe.Busy Or objIe.READYSTATE <> 4): DoEvents: Wend
While objIe.Busy: DoEvents
Wend
Do
Loop Until Not (objIe.Busy)


Dim a As Long

For a = 1 To 8

Set xobj = objIe.Document.getElementById("viewInfo_myApprDataGrid")
Set xobj = xobj.getElementsByClassName("lfHead").Item(0)
Set xobj = xobj.getElementsByTagName("td")(a)

Sheets("1").Cells(1, a) = xobj.innerText

Next a
Next id

Set xobj = Nothing
objIe.Quit
Set objIe = Nothing

Application.ScreenUpdating = False

clif
02-05-2021, 10:56 PM
What is the problems? Originally work well with below code





Application.ScreenUpdating = False

Dim objIe As Object, xobj As HTMLDivElement
'Set objIe = CreateObject("InternetExplorer.Application")
Set objIe = New InternetExplorerMedium

objIe.Visible = True



Dim id As Long
Dim Lastrow2 As Long

Sheets("main").Select
With ActiveSheet
Lastrow2 = .Cells(.Rows.Count, "A").End(xlUp).Row

For id = 2 To Lastrow2

objIe.navigate "http://abc.com/id=" & Sheets("main").Cells(custid, 10).Value

' While (objIe.Busy Or objIe.READYSTATE <> 4): DoEvents: Wend
While objIe.Busy: DoEvents
Wend
Do
Loop Until Not (objIe.Busy)


Dim a As Long

For a = 1 To 8

Set xobj = objIe.Document.getElementById("viewInfo_myApprDataGrid")
Set xobj = xobj.getElementsByClassName("lfHead").Item(0)
Set xobj = xobj.getElementsByTagName("td")(a)

Sheets("1").Cells(1, a) = xobj.innerText

Next a
Next id

Set xobj = Nothing
objIe.Quit
Set objIe = Nothing

Application.ScreenUpdating = False