Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Plugging Excel Data In Script

Status
Not open for further replies.

DUnnerstall

Technical User
Apr 4, 2000
13
0
0
US
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.
 
What is the value of F6 in the spreadsheet ?
Why not simply this ?
strIPAddress = objExcel.Cells(2,6).Value

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OOps, sorry for the typo.
What is the value of F[!]2[/!] in the spreadsheet ?
Why not simply this ?
strIPAddress = objExcel.Cells(2,6).Value
 
That works, thank you.
The value of F2 in the spreadsheet is an IP address.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top