Is there a way how to fix the Compile error in VBA

Edovon

New Member
Joined
Sep 9, 2019
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
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

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
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
All of the lines that have Selenium are compile errors.
 
Upvote 0

Forum statistics

Threads
1,215,741
Messages
6,126,587
Members
449,319
Latest member
iaincmac

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