Working with Excel Object Model in UFT – User friendly Tech help

In this video tutorial we are going to discuss, working with Excel in UFT using our “Excel Object Model“.
n
nTopics discussed:-

n

    n

  • Understanding Excel object model(Application, Workbooks, Worksheet,Cell)
  • n

  • Creating the corresponding objects for accessing Excel objects
  • n

  • Fetching single cell data from excel
  • n

  • Fetching data from complete Excel
  • n

  • Writing data into Excel Cell
  • n

  • Changing the Font color of cell in Excel
  • n

  • Changing the Background color of cell in Excel
  • n

n

n

n

n

n

n

n

n

Understanding Excel in UFT

n

Sample Code Snippets:-
n

n

'Creating the Excel Object
set objExcel = createobject("excel.application")
'Creating the Workbooks object
set objWB = objExcel.workbooks.open (Path of Excel)
'Creating the sheet object
set objsheet = objwb.worksheets(SheetName)
'Changing the backgound color all the populated cells in sheet
for i= 1 to objsheet.usedrange.rows.count
for j = 1 to objsheet.usedrange.columns.count objsheet.cells(i,j).interior.color=vbred
next
next
'Saving the workbook after changesobjWb.save
'closing the workbookobjWB.close
'Quit the Excel and destroying the Excel objectobjExcel.Quit
set objExcel=nothing

n

n
n

nIncase below video is not loaded, Click Here

n


n

How to copy Data from Notepad and Paste into Excel
nCode for Adding Hyperlinks in Excel
nHow to get column address from column Name in Excel
nHow to Randomize Excel data?

Was this article helpful?
YesNo

Similar Posts