1
chrome.exeファイルが存在するかどうかを確認し、そうであればブラウザを開きます。私が最初にIf
確認の上
実行時エラー '52' 不正のファイル名または番号
を取得しています。何故ですか?
Sub openChrome()
Dim chromePath32
Dim chromePath64
Dim chromePathUser
Dim current_user
chromePath32 = """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"""
chromePath64 = """C:\Program Files\Google\Chrome\Application\chrome.exe"""
current_user = (Environ$("Username"))
chromePathUser = """c:\users\" & current_user & "\AppData\Local\Google\Chrome\Application\Chrome.exe"""
If Dir$(chromePath32) <> "" Then '<-----error here
Shell (chromePath32 & " -url http:google.co.nz")
ElseIf Dir$(chromePath64) <> "" Then
Shell (chromePath64 & " -url http:google.co.nz")
ElseIf Dir$(chromePathUser) <> "" Then
Shell (chromePathUser & " -url http:google.co.nz")
Else
MsgBox "Chrome installation not found"
Exit Sub
End If
End Sub