Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is the code that I have and that works. If I use the "run" option I get a type mismatch error.
Option Explicit Sub test_function() Dim var_1 As String Dim var_2 As String var_1 = "192.168.10.1" var_2 = get_info(var_1) Debug.Print var_2 End Sub Function get_info(ip As String) As String Dim obj_wsh Dim obj_run Dim var_cmd Dim var_result As String Dim var_lines() As String Set obj_wsh = CreateObject("WScript.Shell") var_cmd = "ping -n 4 -w 30 " & ip ' Set obj_run = obj_wsh.Run("%ComSpec% /c " & var_cmd & "| nul 2&1", 0, True) Set obj_run = obj_wsh.exec("%ComSpec% /c " & var_cmd) var_result = obj_run.StdOut.ReadAll var_lines = Split(var_result, vbCrLf) get_info = var_lines(1) End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Execute command in Right Click through VBA | Excel Programming | |||
Execute a ping command | Excel Programming | |||
How do I execute command from button or hyperlink? | Excel Discussion (Misc queries) | |||
VBA Equivalent of ASP 'Execute' Command | Excel Programming | |||
Execute a menu command with VBA? | Excel Programming |