I have a macro that calls Chrome, however deploying this code on different machines is undermined by the full filepath for chrome being different on each machine. To mitigate this, I wanted to execute a one-time search for "chrome.exe" and to store the filepath as a variable. The below seems to work however the recursiveness generates a stack space issue (Run-time error 28).
This seems such a simple operation, and recursive searches are all over the usual forums, yet I cannot get it right!
Function Recurse(sPath As String) As String
Dim FSO As New FileSystemObject
Dim myFolder As Folder
Dim mySubFolder As Folder
Dim myFile As File
Application.ScreenUpdating = False
Set myFolder = FSO.GetFolder("C:\")
For Each mySubFolder In myFolder.SubFolders
For Each myFile In mySubFolder.Files
If myFile.Name = "chrome.exe" Then
Debug.Print myFile.Name & " in " & myFile.Path
Exit For
End If
Next
Recurse = Recurse(mySubFolder.Path)
Next
Application.ScreenUpdating = True
End Function
Sub ChromeSearch()
Call Recurse("C:\")
End Sub