0

I have this code and would like it to convert it to work for chrome instead of IE:

For Each htmlEle In ieObj.Document.getElementsByClassName("data data14902")(0).getElementsByTagName("tr")
   With ActiveSheet
      .Range("A" & i).Value = htmlEle.Children(0).textContent
      .Range("B" & i).Value = htmlEle.Children(1).textContent
      .Range("C" & i).Value = htmlEle.Children(2).textContent
      .Range("D" & i).Value = htmlEle.Children(3).textContent
      .Range("E" & i).Value = htmlEle.Children(4).textContent
      .Range("F" & i).Value = htmlEle.Children(5).textContent
      .Range("G" & i).Value = htmlEle.Children(6).textContent
      .Range("H" & i).Value = htmlEle.Children(7).textContent
      .Range("I" & i).Value = htmlEle.Children(8).textContent
      .Range("J" & i).Value = htmlEle.Children(9).textContent
      .Range("K" & i).Value = htmlEle.Children(10).textContent
      .Range("L" & i).Value = htmlEle.Children(11).textContent
   End With

   i = i + 1
Next htmlEle

This is only a chunk of the code. What I'm doing is navigating to a particular webpage with a data table and what I want to do is copy all the data and paste it into excel. Also, if there are parts of the code that can be improved, I'm open to it!

  • Can we view the url? – QHarr Jun 07 '22 at 23:05
  • 2
    To use Chrome from VBA you'll need to install and use Selenium Basic - see for example https://www.guru99.com/excel-vba-selenium.html or https://officetricks.com/excel-vba-selenium-library-chrome-web-data-extract-sample-code/ – Tim Williams Jun 07 '22 at 23:06
  • I agree with what Tim Williams metioned, if you want to implement automation in VBA, you need to use Selenium Basic. By the way, you need to download the appropriate version of the driver to replace the driver that comes with the SeleniumBasic package. Just refer to this case: [Using Google Chrome in Selenium VBA](https://stackoverflow.com/questions/57216623/using-google-chrome-in-selenium-vba-installation-steps). – Xudong Peng Jun 08 '22 at 02:29
  • I have this chunk from a module I wrote a while ago. The module I'm writing now is using selenium (I want to use it on chrome instead of IE). I am currently able to navigate to the webpage I need to pull the data from on chrome. I suppose what I'm asking for is how to change the syntax of the code I posted so that it works with the chrome driver instead of just internet explorer – rookiecode Jun 08 '22 at 16:02

0 Answers0