12
Visual Basic for Applications를 사용하여 다음과 같은 셸 명령을 실행하고 싶습니다.VBA를 사용하여 셸 명령을 실행하려면 어떻게해야합니까?
C:\Temp\gc.exe 1
어떻게하면됩니까?
Visual Basic for Applications를 사용하여 다음과 같은 셸 명령을 실행하고 싶습니다.VBA를 사용하여 셸 명령을 실행하려면 어떻게해야합니까?
C:\Temp\gc.exe 1
어떻게하면됩니까?
이것은 당신이 exe 파일을 호출하고 쉘 명령을 사용하여에 인수를 전달하려는 시나리오를 보여줍니다.
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
: 다음 코드는 인수로 URL을 전달하여 (당신은 크롬을 설치 한 가정) chrome.exe의이 거주하고에서가, www.google.com를 호출 폴더를 검사합니다