Formatting Excel output from QuickTest Professional
You can use the Excel object model to automate formatting the values in a cell in an Excel worksheet.
Example:
filename = "C:\temp\Book1.xls"
Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.Workbooks.Open filename
Set NewSheet = ExcelObj.Sheets.Item(1)
' Add the text - format bold
NewSheet.Cells(1,2) = "Hello From QTP!"
NewSheet.Cells(1,2).Font.Bold = true
' Add the text - format color
NewSheet.Cells(2,2) = "Hello From QTP!"
NewSheet.Cells(2,2).Font.Color = RGB(0, 0, 255)
' Add the text - format italic
NewSheet.Cells(3,2) = "Hello From QTP!"
NewSheet.Cells(3, 2).Font.Italic = true
' Add the text - format size
NewSheet.Cells(4,2) = "Hello From QTP!"
NewSheet.Cells(4, 2).Font.Size = 25
' Add the text - format Strikethrough
NewSheet.Cells(5,2) = "Hello From QTP!"
NewSheet.Cells(5, 2).Font.Strikethrough = true
' Add the text - format underline
NewSheet.Cells(6,2) = "Hello From QTP!"
NewSheet.Cells(6, 2).Font.Underline = true
' Add the text - format Subscript
NewSheet.Cells(7,2) = "1st test"
NewSheet.Cells(7, 2).Characters(2, 2).Font.Subscript = True
' Add the text - format Subscript
NewSheet.Cells(8,2) = "1st test"
NewSheet.Cells(8, 2).Characters(2, 2).Font.Superscript = True
ExcelObj.ActiveWorkbook.Save
ExcelObj.Application.Quit
Set ExcelObj = Nothing