I'm trying to get some tables from the web to put in excel and in my VBA code I'm receiving an error on VBA below I will post my code and if someone can check where is the error, and what I need to do to fix it the problem that I'm having. Thank you.
Problem pic
Problem pic
VBA Code:
Sub GoToSpace()
Dim BaseURL As String
Dim NextURL As String
Dim DateOptions As Selenium.WebElements
Dim DateOption As Selenium.WebElement
Dim tbls As Selenium.WebElements
Dim t As Selenium.WebElement
Dim ws As Worksheet
BaseURL = "https://finance.yahoo.com/qoute/SPCE/options"
Set cd = New Selenium.ChromeDriver
cd.Start
cd.Get BaseURL
cd.FindElementByCss("button").Click
Set DateOptions = cd.FindElementsByCss("option")
Set ws = ThisWorkbook.Worksheets.Add
For Each DateOption In DateOptions
NextURL = BaseURL & "?date=" & DateOption.Attribute("value")
cd.ExecuteScript "window.open(arguments[0])", NextURL
cd.SwitchToNextWindow
Set tbls = cd.FindElementsByCss("table")
For Each t In tbls
t.AsTable.ToExcel ws.Range("A1048576").End(xlUp).Offset(1, 0)
Next t
cd.Window.Close
cd.SwitchToPreviousWindow
Next DateOption
ws.Range("A1").Value = Now
ws.Range("A1").CurrentRegion.EntireColumn.AutoFit
End Sub