QTP VBScript new series + Interview Question Bank on QTP for enrichment of Knowledge in QTP

This Site has been brought to you by HP Certified Expert of QTP.

Exciting new articles for October:

1) QTP Tip:Deselect all Radio Buttons

2) HP QTP Crypt Object

3)Adding Hyperlinks in Excel Spreadsheet

Best of Luck Friends ! ! !

Expert QTP

All Articles are Copyright Protected. These are Free for Reading & Personal Use. Reproduction in Any Form without the Permission is Illegal & Strictly Prohibited.

Copyright © 2009 ExpertQTP

Google Search

Thursday, October 27, 2011

QTP Add Comment Excel Object

The following code will add a comment in a particular cell in excel worksheet.

Set oExcel=CreateObject("Excel.Application")


Set oWorkBook=oExcel.Workbooks.Add

Set oWorkSheet=oWorkBook.Worksheets(1)

With oWorkSheet.Cells(1,1).AddComment

.Visible = False

.Text "Comment for Cell 1,1"

End With

In case, you want to update the comment, use the following code:

With oWorkSheet.Cells(1,1).Comment

.Visible = True

.Text "Comment Text Changed"

End With


Thursday, October 22, 2009

QTP Tip: Deselect all radio buttons

Yesterday I got an email from one of my esteemed readers who asked "Is there any way to deselect all radio buttons using HP QTP?" I thought why one would do that but since it has been asked, it has to be answered.

Before answering the above question let me explain that, radio buttons work in groups unlike checkboxes. It means, in a group only a single radio button can be selected. Afterwards, its not possible to deselect all radio buttons in that group. Even manually it can not be done.

Inititally the task seems impossible but its not :)

It is definitely possible to deselect all radio buttons using QTP but it can only be achieved with the help of Document Object Model or DOM.

The QTP Script for the same goes here:

Set Obj = Browser("Google").Page("Google").object.getElementsByTagName("INPUT")

For each RadioBtn in Obj
If lcase(RadioBtn.type) = "radio" Then RadioBtn.checked = False

To know more about the Document Object Model in QTP, see here :

Also read about the Object property in WebRadioGroup Object in QTP help for more information.


Document Object model is supported by Internet Explorer browser only & not for Firefox as the underlying COM technology is not supported by Firefox. Hence, for Firefox browser, QTP will not be able to access the radio buttons using Document Object Model.

Also working with Document Object Model inside HP Quicktest Professional is faster in terms of performance as no object identification is involved.


Sunday, October 4, 2009

QTP: Adding Hyperlinks in Excel Spreadsheet

I was playing with the excel application along with QTP when suddenly I thought of adding a hyperlink inside an Excel spreadsheet from Quicktest. Task seemed a bit tricky initially but I took up the challenge and finally created a script.

The QTP script to accomplish the same goes here:

'Create an object reference to Excel. Also you can see "Excel.exe" 'process gets created in the Task Manager
Set objExcel = CreateObject("Excel.Application")

'Make the invisible Excel application visible
objExcel.Visible = True

'Add a workbook to the blank excel sheet
Set objWorkbook = objExcel.Workbooks.Add

'Get the handle of first sheet
Set objWorksheet = objWorkbook.Worksheets(1)

'Enter the value in A1 cell inside your first worksheet
objWorksheet.Cells(1, 1) = "QTP Expert"

'Create a range encompassing only the single cell A1
Set objRange = objExcel.Range("A1")

'Add a hyperlink to that range. Here range is only a single 'cell so hyperlink would be created
Set objLink = objWorksheet.Hyperlinks.Add _
(objRange, "")

If you like this Article, I would suggest you to subscribe my RSS feed. This way you will get all new future articles directly into your mailbox.


Copyright © 2009 ExpertQTP