Ask a Question

I have an requirement to read Comments present in cells of spreadhseet from Excel.

SOLVED
sudit
New Contributor

I have an requirement to read Comments present in cells of spreadhseet from Excel.

Hi,

 

I have a requirement to read Comments from Excel Cells.With TestComplete I tried using Sys.OleObject("Excel.Application") and navigated to repsective sheet.

Later i used the below command:-

 

Excel.Worksheets(4).Range("B1").Comment.Text;

 

I get an error stating Object doesnt support this property or method.

 

Can anyone help me with a solution to read the comment of the cell.

 

Thanks

Sudit

 

5 REPLIES 5
Colin_McCrae
Community Hero

Don't think you want to use "Range". Thats for capturing a number of cells.

 

Change range to "Cell(x,y)" instead.

 

When you say comments, is this just standard text contained in a cell or is it like a tooltip type popout comment? 

joseph_michaud
Moderator

"Text" is a method, not a property.  Use

 

Excel.Worksheets(4).Range("B1").Comment.Text();

 

See Comment.Text Method (Excel)

Hi Colin,

 

I did try with Cell(x,y) but it didnt work out.

Also as you rightly guessed Comment is like a tooltip popup comment.

Think your answer might be a combination of both answers.

 

For an individual cell, you should probably use "Cell" rather than "Range" but what @joseph_michaud says about your syntax is probably right. I've never tried to retrieve comment type text from Excel before so not sure ....

 

(I guess "Range" will work if you give it a range of a single cell, but suspect "Cell" would make more sense)

dmiscannon
Frequent Contributor

The answer provided by joseph_michaud worked for me. Have you tried it yet?

cancel
Showing results for 
Search instead for 
Did you mean: