VBA can't fetch HTML elements

dionysus_83

New Member
Joined
Feb 24, 2016
Messages
30
Before you say... search in duplicate posts, well, I did and I don't understand what I've done wrong to be able to help myself.

In general, I need table from this page. Ive tried with table queries too to fetch entire table, but with no luck. So I've tried InnerText with grabbing by elements, no luck! Then again by elements by trough parent.child looping. No luck again!

When I go trough debugging I noticed that it can't find it under "ember4675" while it is clearly on the page source...


Part of HTML is in this link: https://pastebin.com/Bq79a0a4

And here is the code:

Code:
Sub IMPORTMILLS()

Dim x As Long
Dim xObject As Object
Dim xCollection As Object
Dim xButton As Object
Dim xDOC As HTMLDocument
Dim xIE As New InternetExplorer
Dim UN As String
Dim UP As String


UN = Sheets("Username&Passwords").Range("C3")
UP = Sheets("Username&Passwords").Range("D3")


xIE.Visible = True
xIE.navigate "https://go.tradegecko.com/account/sign_in"


With xIE
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
End With
Application.Wait (Now + TimeValue("0:00:05"))


Set xDOC = xIE.document


On Error Resume Next
Set xUN = xDOC.getElementById("user_email")
xUN.Value = UN
Set xUP = xDOC.getElementById("user_password")
xUP.Value = UP




Set xButton = xDOC.getElementById("login")


xButton.Click
On Error GoTo 0


With xIE
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
End With
Application.Wait (Now + TimeValue("0:00:05"))


xIE.navigate "https://go.tradegecko.com/inventory"
With xIE
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
End With
Application.Wait (Now + TimeValue("0:00:05"))


Set xDOC = xIE.document
Set xTable = xDOC.getElementById("ember4675")


xLength = xTable.Length


    With ThisWorkbook.Sheets("TempList")
        For rowNum = 0 To xTable.Children.Length - 1
            For colNum = 0 To xTable.Children(rowNum).Children.Length - 1
                .Cells(rowNum + 1, colNum + 1) = xTable.Children(rowNum).Children(colNum).innerText
            Next colNum
        Next rowNum
    End With


End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,214,415
Messages
6,119,382
Members
448,889
Latest member
TS_711

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top