Launch Chrome Browser

The first step in using Selenium Basic to launch a browser is to add the "Selenium Type Library" to your VBA Project. The steps for adding the "Selenium Type Library" are as follows.


  • 1. Click on "Tools" and then select "References" from the drop-down menu. The 'Reference - VBAProject' window will be opened in a new window.
  • 2. Next, you need to look for "Selenium Type Library" in the list. Once you have located the library, select it by checking the box and clicking on "OK" to add it to your VBA project.

It is now time to code. To properly clarify the steps, we have incorporated comments for each block of code.

							
  'In order to prevent Chrome from closing once the macro is executed,
  'a variable of type ChromeDriver must be declared outside of the subroutine.
    Private Driver As Selenium.ChromeDriver

	Sub OpenAutomationFeverWebsite()
	   'Create instance of the ChromeDriver
		   Set Driver = New Selenium.ChromeDriver
		
		'Launch the chrome browser
			  Driver.Start
			  
		 'Navigate to automationfever.com
			  Driver.Get "https://www.automationfever.com/"
			  
		  'Maximize the browser window
			 Driver.Window.Maximize
	End Sub
	

VB Editor Window will look like below:

When you run the code, it will open the Chrome browser and go to www.automationfever.com. The screenshot of the Chrome is shown below.

Stay connect with us.