Results 1 to 8 of 8

Thread: Excel VBA: How To: Read/Write/Edit Cell COMMENTS [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Resolved Excel VBA: How To: Read/Write/Edit Cell COMMENTS [RESOLVED]

    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:
    Code:
    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.
    Last edited by Webtest; Jun 26th, 2006 at 12:33 PM.
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width