Monday, August 26, 2013

Update Cell Value In Excel - QTP

Function Fn_UpdateCellValueInExcel(strFilePath,strUID,strSheetName,strColumnName,strColumnValue)
 Dim objConnection, strSQL, objRecordSet, intRow, strUniqueValue, strSystemTempDir

 'Setting default values of FilePath and SheetName
 If strSheetName = "" Then
  strSheetName = "Sheet1"
 End If

 Set objConnection = getDBConnectionExcelObject (strFilePath)  'Available in another post
 objConnection.Open

 strSQL = "UPDATE [" & strSheetName & "$]"&" SET "&strColumnName&"= '" &strColumnValue & "' WHERE TestCaseName = '" &strUID & "'"
 objConnection.Execute strSQL

 closeDBConnectionObject(objConnection)
 CustomReporter micInfo, "Parameter Updated info","Parameter: " &strColumnName &"of Test Case:" &strTestCaseName &"Has been updated to:" &strColumnValue
End Function

No comments:

Post a Comment