Micro Focus QTP (UFT) Forums
Creating column names in an Excel ss - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Creating column names in an Excel ss (/Thread-Creating-column-names-in-an-Excel-ss)



Creating column names in an Excel ss - mv8167 - 06-13-2011

After creating a blank spreadsheet in Excel, how do I add column names?

thx for looking


RE: Creating column names in an Excel ss - vijayendra.shukla - 06-13-2011

Are you trying to write run time results in the spreadsheet? Maybe you can explain a bit about what you are doing.


RE: Creating column names in an Excel ss - mv8167 - 06-14-2011

i am taking object Link names and a few other values and copying them to a spreadsheet to use in another test.

I need the column name for future testing.

This did not work ror QTP 9.5

excelSheet.Cells(1,1).Value = "Row"


RE: Creating column names in an Excel ss - mv8167 - 06-14-2011

I tried objExcel, and this did not work. Getting error message:

Object required: 'objExcel'

Line (98): "objExcel.Cells(1,1).Value = "Row"".

objExcel.Cells(1,1).Value = "Row"


RE: Creating column names in an Excel ss - parminderdhiman84 - 06-14-2011

The error you are getting is because the object is not defined. please define the excel object first. Refer to below code :

Code:
Filename="<your path>"
    Dim objExcel
    Set objExcel = createobject("Excel.application")
    objExcel.DisplayAlerts = False
    Set oBook = objExcel.Workbooks.Open(Filename)
    Set oSheet = objExcel.Activesheet

    objExcel.Cells(1,1).Value = "Row"

    oBook.SaveAs (Filename)
    objExcel.Workbooks.Close()
    Set oSheet=Nothing
    Set oBook=Nothing
    Set objExcel=Nothing

Regards,
Parminder


RE: Creating column names in an Excel ss - mv8167 - 06-14-2011

Parminder

Thx Parminder. I just realized I was setting one obj as objTbl another as objExcel. Thx for helping me zsee my mistakes and providing me code that works ;-)




RE: Creating column names in an Excel ss - vijayendra.shukla - 06-14-2011

Another way could be:

Create Parameters in the run-time datatables within QTP and save values for different columns for each iteration in those different parameters. This will be helpful if you are running multiple iteration of that action and capturing links and other details.

Once all the iterations are complete, you can export the run-time datatable to your machine or any shared repository. When you export the datatable, it will contain the Parameter names as the columns. You should be able to use this newly created excel file for your next test or for future. I hope you understand what I am trying to say and I am sorry if I confused you.