Friday, April 9, 2010

VBScript - How Can I Locate and Replace Information for a Specific Item in a Spreadsheet?

VBScript - How Can I Locate and Replace Information for a Specific Item in a Spreadsheet?

On Error Resume Next

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Scripts\Inventory.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes;"";"

objRecordset.Open "Select * FROM [Sheet1$]", _
objConnection, adOpenStatic, adLockOptimistic, adCmdText

strSearchCriteria = "Name = 'atl-fs-01'"
objRecordSet.Find strSearchCriteria

objRecordset("IPAddress") = "192.168.1.100"
objRecordset.Update

objRecordset.Close
objConnection.Close

[Via]