根据[此链接] [1],@ ray使用以下代码进行浏览
shell("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -url www.google.com")
虽然我想使用动态网址
Dim url as string
url = "www.google.com/translate"
Dim wholeContent as String
wholeContent = ""C:\Program Files (x86)\Google\Chrome\Application\chrome.exe - url"" & url
Shell(wholeContent)
下次可能是地图而不是翻译。
答案 0 :(得分:2)
以下是在Chrome中打开网址(32位或64位版本)或使用默认浏览器(如果无法找到Chrome)的子程序。我希望这会有所帮助。
Sub OpenInChromeOrDefaultBrowser(ByVal url As String)
Dim wholeContent As String
chrome = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
If Dir(chrome, vbNormal) <> "" Then
'' 32 bit Chrome
wholeContent = """" & chrome & """ -url " & url
Else
'' 64 bit Chrome
chrome = "C:\Program Files\Google\Chrome\Application\chrome.exe"
wholeContent = """" & chrome & """ -url " & url
End If
If Dir(chrome, vbNormal) <> "" Then
'' Chrome is found, execute
Shell wholeContent
Else
'' Chrome was not found, open url using the default program
Dim Sh As Object
Set Sh = CreateObject("WScript.Shell")
Sh.Run url
End If
End Sub