0

I am trying to figure out a way to navigate to Chrome in Vba

This works but i am unsur why I needs to be declared as a variable.

Additionally, if the cell I is refrencing is empty then it will not open it is there and way to open and navigate to a page without having it refrence the workbook

Sub multiplechrome()

Dim WebUrl As String
Dim i As Integer

For i = 1 To ActiveSheet.Cells(1, 2).Value
    WebUrl = "http://" & Cells(i, 1).Value & """"
    Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -url " & WebUrl)

Next
End Sub
braX
  • 11,506
  • 5
  • 20
  • 33
  • `i` is the row number. – BigBen Mar 23 '22 at 18:53
  • Can't you install software on the machine? The only way that I know to navigate in Chrome is by using Selenium, which is available for [Excel VBA](https://stackoverflow.com/questions/57216623/using-google-chrome-in-selenium-vba-installation-steps). If you don't have selenium you can only open webpages with VBA, and that's basically it. – Sgdva Mar 23 '22 at 20:18

1 Answers1

0

You can set WebUrl to a default value.

Then if the cell is (not null and is not empty and is not blank) then you re-set weburl to the cell value.

Not tested, but try something like:

WebUrl = "chrome://newtab"
if isNull(Cells(i,1).Value) <> true AND isEmpty(Cells(i,1).Value) <> true AND Cells(i,1).Value <> "" then
WebUrl = "http://" & Cells(i, 1).Value & """"
end if

The obvious next bug is assuming the value is a valid url.

Yorik
  • 116
  • 2