Hi ,

After Getting the Cell value from excel sheet use this fn, it will update
the value..


'To get value from Excel file
Function GetData(ByVal strFilePath,ByVal strSearchText)
Dim oWorkSheets
Dim oExcel:Set oExcel=CreateObject("Excel.Application")
oExcel.Visible=False
oExcel.DisplayAlerts=False
Set oWorkSheets=oExcel.WorkBooks.Open(strFilePath).WorkSheets(1)
GetData=oWorkSheets.Cells(Split(oWorkSheets.Range("A:A").Find(strSearchText).Address,"$")(2),2).Value
oExcel.Quit
Set oWorkSheets=Nothing
Set oExcel=Nothing
strFilePath=Empty
strSearchText=Empty
End Function

'To Write the value to Excel file
Function WriteData(ByVal strFilePath,ByVal strID,ByVal strData)
Dim oWorkSheets,inUsedCount
Dim oExcel:Set oExcel=CreateObject("Excel.Application")
oExcel.Visible=False
oExcel.DisplayAlerts=False
Set oWorkSheets=oExcel.WorkBooks.Open(strFilePath).WorkSheets(1)
inUsedCount=oWorkSheets.UsedRange.Rows.Count
oWorkSheets.Cells(inUsedCount+1,1).Value=strID
oWorkSheets.Cells(inUsedCount+1,2).Value=strData
oExcel.WorkBooks(1).Save
oExcel.Quit
Set oWorkSheets=Nothing
Set oExcel=Nothing
strFilePath=Empty
End Function


Function ExcelDtaIO(sXls,sSht,sRow,sFld,sDta)
      On Error Resume Next
      Dim objExcel, objWorkBook, objSheet
      Set objExcel = CreateObject("Excel.Application")
      Set objWorkBook = objExcel.Workbooks.Open(sXls)
      Set objSheet = objWorkBook.Worksheets(sSht)

      '***  Get column number based on field name  ***
      CurCol = 1
      CurColNum = 0
      Do While Trim(objSheet.Cells(1, CurCol).Value) <> Empty
         CurCellVal = Trim(objSheet.Cells(1, CurCol).Value)
         If CurCellVal = sFld Then
            CurColNum = CurCol
            Exit Do
         End If
         CurCol = CurCol + 1
      Loop

      If sRow = "" Then
      sRow = DataTable.GetSheet(sSht).GetCurrentRow
      End If

      '***  Put to or Get from specific cell of current excel file  ***
      If sDta <> Empty Then
         '***  Update specific cell of current excel file  ***
         objSheet.Cells(sRow+1, CurColNum).Value = sDta
         objWorkBook.Save
         ExcelDtaIO = Empty
      Else
         ExcelDtaIO = Trim(objSheet.Cells(sRow+1, CurColNum).Value)
      End If
      objWorkBook.Close True

      '***  Destroy objects created by this fucntion  ***
      Set objSheet =  Nothing
      Set objWorkBook = Nothing
      Set objExcel = Nothing

   End Function


Happy Tester,
Byzoor,




On Sat, Jul 16, 2011 at 8:03 AM, uma mahesh <[email protected]> wrote:

> IC Ok then you can use this code
>
> Option Explicit
> Dim var1, var2, var3, rc, i, agent, pass
> Set var1=createobject("Excel.application")
> Set var2=var1.workbooks.open("path of excel sheet")
> Set var3=var2.worksheets("sheet1")
> rc=var3.usedrange.columns.count  ' this will give the no.of links
> available in the coulmn
> MsgBox rc
> For i=1 to rc
> link=var3.cells("1", i)
> Next
>
> --
> You received this message because you are subscribed to the Google
> "QTP - HP Quick Test Professional - Automated Software Testing"
> group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/MercuryQTP?hl=en
>

-- 
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

Reply via email to