0

I have a small Macro taking me a to a website on Chrome using a shell command, but I'm hoping to chain it to another that populates the username and password on the site. Is this possible? My code so far:

Sub Logintest2()

  Dim chromePath As String

  chromePath = """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"""

  Shell (chromePath & " -url http://www.google.com")

End Sub
Brian M Stafford
  • 8,483
  • 2
  • 16
  • 25

1 Answers1

0

I found a post on Reddit that says this is much easier using Internet Explorer since Excel/VBA has some built in interop. However, if you're anything like me you abhor IE.

The same Reddit post suggested a third party plug-in called Selenium Basic. I used this answer to download and install it.

The following code successfully opened Google in Chrome and set the text of the search box to "This is a test".

Sub Test()
    Dim bot As New WebDriver
    
    bot.Start "chrome", "https://www.google.com"
    bot.Get "/"
    
    bot.FindElementByName("q").SendKeys "This is a test"
    Stop

End Sub

I used DevTools (F12) to explore the web content and find that the search box has name="q".

Good luck!

BoilermakerRV
  • 299
  • 1
  • 8
  • Many thanks. I'm creating a link for a team of people and getting them all to download Selenium is unlikely. IE would be fine if that's the way it has to be. I'm still struggling on getting the username and password to auto-populate though. Any thoughts? – ChrisknowsabitofVBA Oct 08 '20 at 15:22