how to add excel comments into array?

adrivetest

Member
Joined
May 19, 2009
Messages
5
Programming Experience
Beginner
hi,

i was wondering if it's possible to convert excel's cell comments into an array through the same way we can when converting excel's cell text into array like this :

where arrValue is Object, and xlSheet is Sheet object

VB.NET:
arrValue = xlSheet.Range("A1:B5").Value


can we do something similarly for comment text?
 
Range has a Comment property, which has a Text property...
 
yeas...but unforetunately, that won't work as it'll throw nullreferenceexception like "Object reference not set to an instance of an object."
 
You have to do a for each Range in your range selection and get the Comment for each cell.
VB.NET:
Dim rangeComments As New List(Of String)
For Each cell As Excel.Range In sheet.Range("A1:A2")
    rangeComments.Add(cell.Comment.Text)
Next
 
ah...that's what i was trying to avoid :(

actually, i have alot of cells on the sheet, and to loop each cells with comments into an array, it'll take awhile.

If i could use it like how i assign cell text values directly into an arrray without looping, it would've saved a lot
 
Back
Top