DUnnerstall
Technical User
I am trying to plug an IP address from Excel into a script to ping it. My code to assign the IP to a string is:
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("c:\BankIP\branchiptest.xls")
strIPAddress = Array(objExcel.Cells(2,6).Value)
And the script goes like this:
Dim WSHShell, rtnCode
Const WindowStyle = 0
Const WaitOnReturn = True Set WSHShell = CreateObject("WScript.Shell")
rtnCode = WSHShell.Run("Ping -n 1 -w 1 " + strIPAddress, WindowStyle, WaitOnReturn)
Set WSHShell = Nothing
MsgBox(rtnCode)
But it is unsuccessful. rtncode has a value of null. If I assign an actual IP address to strIPAddress it runs.
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("c:\BankIP\branchiptest.xls")
strIPAddress = Array(objExcel.Cells(2,6).Value)
And the script goes like this:
Dim WSHShell, rtnCode
Const WindowStyle = 0
Const WaitOnReturn = True Set WSHShell = CreateObject("WScript.Shell")
rtnCode = WSHShell.Run("Ping -n 1 -w 1 " + strIPAddress, WindowStyle, WaitOnReturn)
Set WSHShell = Nothing
MsgBox(rtnCode)
But it is unsuccessful. rtncode has a value of null. If I assign an actual IP address to strIPAddress it runs.