2010-02-18 16 views

Respuesta

2

Esto muestra los escenarios en los que desea llamar un archivo exe y pasar un argumento a él utilizando comandos de la shell. El siguiente código comprueba la carpeta en la que reside chrome.exe y llamar a www.google.com, a partir de ahí (asumiendo que ha instalado cromo) pasando como argumento url:

Public Sub Display_Google() 
    Dim chromePath As String 
    chromePath = "C:\Program Files\Google\Chrome\Application\chrome.exe" 

    If FileExists(chromePath) Then 
    Shell (chromePath & " -url" & " " & "www.google.com"), vbMaximizedFocus 
    Else 

    chromePath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" 
    Shell (chromePath & " -url" & " " & "www.google.com"), vbMaximizedFocus 
    End If 
End Sub 

Public Function FileExists(ByVal FileName As String) As Boolean 
    On Error Resume Next 
    FileExists = Not CBool(GetAttr(FileName) And (vbDirectory Or vbVolume)) 
    On Error GoTo 0 
End Function 
Cuestiones relacionadas