The highlighting of the table is disabled because this page uses the compatibility mode of Internet Explore

Corried

Board Regular
Joined
Dec 19, 2019
Messages
217
Office Version
  1. 2019
Platform
  1. Windows
  2. Web
Hello Excel Pros, around the World.

I have a problem>

I am trying to login my portfolio by signing my email and password to access data tables from in investing.com website.

I created a short video that shows my current problem. If you are open in helping me. It would be greatly appreciated.


In video time 1:39, a yellow bar indicates "The highlighting of the table is disabled because this page uses the compatibility mode of Internet Explorer". you will also find that the web page does not display properly.

Base the information provided.

How can I work around this?


Thanks in advance

Cheers

https://drive.google.com/file/d/1nywatn ... sp = sharing
 
The code stopped when it was supposed to find the table, so it probably performed the previous actions successfully, including the login step
Yes it did. However, when I press end on the error message dialog box. It also end the web link. Please view short video below.

The question is, what should I do from here? How can I go around this?

Thanks in advance

 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
The thing is the test sheet cannot be the active sheet; I will rewrite the code later to overcome this pitfall.

Prepare the test sheet only once and leave it there, no need to type the credentials every time. Use another sheet to receive the data for now, it will be cleared by the code at the start.

Now let’s see if the code can find the table…
 
Upvote 0
Prepare the test sheet only once and leave it there, no need to type the credentials every time. Use another sheet to receive the data for now, it will be cleared by the code at the start.
Ok. I got you thanks. Would wait on your reply later on.

Greatly appreciated
 
Upvote 0
This version uses a sheet named table to receive data. I am not sure that your table will have the same X path as mine, the only way to find out is trying…

VBA Code:
Public driver As New ChromeDriver

Sub Corr()
Dim pt As WebElement, i%, tx$, j%, k%
Sheets("table").Activate                                                    ' sheet to receive data
Cells.ClearContents                                                         ' Clear sheet <===
driver.get "https://www.investing.com/portfolio/"
Application.Wait Now + TimeValue("0:00:03")
Set pt = driver.FindElementByXPath("//*[@id=""loginFormUser_email""]").SendKeys(CStr(Sheets("test").[a85]))
Set pt = driver.FindElementByXPath("//*[@id=""loginForm_password""]").SendKeys(CStr(Sheets("test").[a86]))
Set pt = driver.FindElementByXPath("//*[@id=""signup""]/a")
pt.Click
Application.Wait Now + TimeValue("0:00:03")
Set pt = driver.FindElementByXPath("//*[@id=""navMenu""]/ul/li[9]/a")
pt.Click
Set pt = driver.FindElementByXPath("//*[@id=""portfolioData_10987384""]/div/table") ' get table
j = 1
For i = 1 To pt.FindElementsByTag("tr")(1).FindElementsByTag("th").Count    ' table header
    Cells(1, j) = pt.FindElementsByTag("tr")(1).FindElementsByTag("th")(i).Text
    j = j + 1
Next
For i = 2 To pt.FindElementsByTag("tr").Count                               ' table rows
    j = 1
    For k = 1 To pt.FindElementsByTag("tr")(i).FindElementsByTag("td").Count    ' columns
        Cells(i, j) = pt.FindElementsByTag("tr")(i).FindElementsByTag("td")(k).Text
        j = j + 1
    Next
Next
For i = Cells(1, Columns.Count).End(xlToLeft).Column To 1 Step -1
    If WorksheetFunction.CountA(Columns(i)) = 0 Then Columns(i).Delete Shift:=xlToLeft
Next
[a1].CurrentRegion.NumberFormat = "0.0000"
End Sub
 
Upvote 0
Please test this version which gets the AUD web table. The code assumes each table will have a fixed X path. If this is not true, we will have to refer to them in some other way.

How would you like to proceed from here?

We can get other tables and format the worksheet table…

VBA Code:
Public driver As New ChromeDriver

Sub Corr()
Dim pt As WebElement, i%, tx$, j%, k%
Sheets("table").Activate                                                    ' sheet to receive data
Cells.ClearContents                                                         ' Clear sheet <===
driver.get "https://www.investing.com/portfolio/"
Application.Wait Now + TimeValue("0:00:03")
Set pt = driver.FindElementByXPath("//*[@id=""loginFormUser_email""]").SendKeys(CStr(Sheets("test").[a85]))
Set pt = driver.FindElementByXPath("//*[@id=""loginForm_password""]").SendKeys(CStr(Sheets("test").[a86]))
Set pt = driver.FindElementByXPath("//*[@id=""signup""]/a")
pt.Click
Application.Wait Now + TimeValue("0:00:03")
Set pt = driver.FindElementByXPath("//*[@id=""navMenu""]/ul/li[9]/a")
pt.Click
Set pt = driver.FindElementByXPath("//*[@id=""portfolioData_4482070""]/div/table") ' get table
j = 1
For i = 1 To pt.FindElementsByTag("tr")(1).FindElementsByTag("th").Count    ' table header
    Cells(1, j) = pt.FindElementsByTag("tr")(1).FindElementsByTag("th")(i).Text
    j = j + 1
Next
For i = 2 To pt.FindElementsByTag("tr").Count                               ' table rows
    j = 1
    For k = 1 To pt.FindElementsByTag("tr")(i).FindElementsByTag("td").Count    ' columns
        Cells(i, j) = pt.FindElementsByTag("tr")(i).FindElementsByTag("td")(k).Text
        j = j + 1
    Next
Next
For i = Cells(1, Columns.Count).End(xlToLeft).Column To 1 Step -1
    If WorksheetFunction.CountA(Columns(i)) = 0 Then Columns(i).Delete Shift:=xlToLeft
Next
[a1].CurrentRegion.NumberFormat = "0.0000"
End Sub
 
Upvote 0
How would you like to proceed from here?
Hello Worf. I loved it. I am so excited you are helping me out here, eve so often. I check the website to see if you post the code. Thank you.

Yes as you have mention "We can get other tables and format the worksheet table… ":
  1. Yes I would appreciate if I can download all the web worksheet except the "10 Year Bond" web table. Into one (1) excel worksheet, if it can be done.
  2. Next. My question here is this. How can the code download the web table under the "Technical" tab than the price tab? Please view photo below.
 

Attachments

  • Thanks.PNG
    Thanks.PNG
    57.7 KB · Views: 14
Upvote 0
This intermediate version transfers the first three technical web tables to the worksheet:

VBA Code:
Public driver As New ChromeDriver

Sub Corr()
Dim pt As WebElement, i%, tx$, j%, k%, tabs, L%, lr%
tabs = Array("4482070", "4491329", "4491331")                               ' web page tabs
Sheets("table").Activate                                                    ' sheet to receive data
Cells.ClearContents                                                         ' Clear sheet <===
driver.get "https://www.investing.com/portfolio/"
Application.Wait Now + TimeValue("0:00:03")
Set pt = driver.FindElementByXPath("//*[@id=""loginFormUser_email""]").SendKeys(CStr(Sheets("test").[a85]))
Set pt = driver.FindElementByXPath("//*[@id=""loginForm_password""]").SendKeys(CStr(Sheets("test").[a86]))
Set pt = driver.FindElementByXPath("//*[@id=""signup""]/a")
pt.Click
Application.Wait Now + TimeValue("0:00:03")
Set pt = driver.FindElementByXPath("//*[@id=""navMenu""]/ul/li[9]/a")
pt.Click: DoEvents
For L = LBound(tabs) To UBound(tabs)                                        ' loop the page tabs
    lr = Range("a" & Rows.Count).End(xlUp).row + 2
    Set pt = driver.FindElementById("tab_" & tabs(L))
    DoEvents: pt.Click: DoEvents
    Application.Wait Now + TimeValue("0:00:03")
    Set pt = driver.FindElementByXPath("//*[@id=""technical""]/a")
    pt.Click: DoEvents
    Application.Wait Now + TimeValue("0:00:03")
    Set pt = driver.FindElementById("sortable")
    j = 1
    For i = 1 To pt.FindElementsByTag("tr")(1).FindElementsByTag("th").Count    ' table header
        Cells(lr, j) = pt.FindElementsByTag("tr")(1).FindElementsByTag("th")(i).Text
        j = j + 1
    Next
    For i = 2 To pt.FindElementsByTag("tr").Count                               ' table rows
        j = 1
        For k = 1 To pt.FindElementsByTag("tr")(i).FindElementsByTag("td").Count    ' columns
            Cells(i + lr, j) = pt.FindElementsByTag("tr")(i).FindElementsByTag("td")(k).Text
            j = j + 1
        Next
    Next
Next
For i = Cells(3, Columns.Count).End(xlToLeft).Column To 1 Step -1               ' delete empty columns
    If WorksheetFunction.CountA(Columns(i)) = 0 Then Columns(i).Delete Shift:=xlToLeft
Next
End Sub
 
Upvote 0
Solution
Worf. I love you Bro... This is exactly what I am looking for. Please tell me which part of the code can I adjust to download, up to the second to last tab. If you are open of course.

Thanks you for your patience and your continual support you have given unto me and others after...

Thanks in advance.

Really appreciate it a lot.

Thank you
 
Upvote 0
You are welcome...

There are web tabs not initially visible when the page loads. We will probably have to scroll them into view either directly by code or button clicking…

It is dinner time so I will be back tomorrow.
 
Upvote 0
You are welcome...

There are web tabs not initially visible when the page loads. We will probably have to scroll them into view either directly by code or button clicking…

It is dinner time so I will be back tomorrow.
Ok. Thank you. Hope dinner was wonderful.
 
Upvote 0

Forum statistics

Threads
1,216,210
Messages
6,129,525
Members
449,515
Latest member
lukaderanged

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