Webtest
Jun 25th, 2006, 09:09 AM
Esteemed Forum Participants and Lurkers:
===============================
Excel '97, Excel 2003 VBA
Does anyone have any clues about how to Read and Write the COMMENT attached to a Cell? I have tried a few things directly from the HelpHeap, and they have all failed! Here are some things I have tried:Dim aRange As Range
Set aRange = ActiveWorkbook.ActiveSheet.Range("E8")
'This Works!
Range("E6").Comment.Visible = True
'This generates an error if a comment already exists, but works the first time!
' Application defined or object defined error.
aRange.Offset(1, 0).AddComment
'This works ... but ONLY IF a comment field ALREADY EXISTS
' Object variable or With block variable not set
aRange.Offset(1, 0).Comment.Text "We CHANGED this Text!"
'This works whether or not a Comment already exists
aRange.Offset(2, 0).NoteText "This is TOTAL GARBAGE!"
How do I tell if a Comment field ALREADY EXISTS for a Cell?
More importantly, how do I READ an existing comment so that I can edit it?
EDIT: P.S. ... This works to Read the existing comment, but generates an error if there is no comment ...
tStr = aRange.Comment.Text
So, that still leaves the question of determining IF a comment already exists. Do I have to force a STUPID ERROR and then handle it? (I HATE that!).
Thank you for any and all comments, suggestions, and assistance.
===============================
Excel '97, Excel 2003 VBA
Does anyone have any clues about how to Read and Write the COMMENT attached to a Cell? I have tried a few things directly from the HelpHeap, and they have all failed! Here are some things I have tried:Dim aRange As Range
Set aRange = ActiveWorkbook.ActiveSheet.Range("E8")
'This Works!
Range("E6").Comment.Visible = True
'This generates an error if a comment already exists, but works the first time!
' Application defined or object defined error.
aRange.Offset(1, 0).AddComment
'This works ... but ONLY IF a comment field ALREADY EXISTS
' Object variable or With block variable not set
aRange.Offset(1, 0).Comment.Text "We CHANGED this Text!"
'This works whether or not a Comment already exists
aRange.Offset(2, 0).NoteText "This is TOTAL GARBAGE!"
How do I tell if a Comment field ALREADY EXISTS for a Cell?
More importantly, how do I READ an existing comment so that I can edit it?
EDIT: P.S. ... This works to Read the existing comment, but generates an error if there is no comment ...
tStr = aRange.Comment.Text
So, that still leaves the question of determining IF a comment already exists. Do I have to force a STUPID ERROR and then handle it? (I HATE that!).
Thank you for any and all comments, suggestions, and assistance.