Bug Hunting Session
Bug 106278 - Worksheet Comment Parent is Nothing, expecting a Range object of associated cell
Summary: Worksheet Comment Parent is Nothing, expecting a Range object of associated cell
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.2.5.1 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: needsDevAdvice
Depends on:
Blocks: Calc-Comments
  Show dependency treegraph
 
Reported: 2017-03-02 10:50 UTC by Aaron J. Peterson
Modified: 2017-11-01 23:11 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron J. Peterson 2017-03-02 10:50:44 UTC
Description:
Comment objects do not have a Parent property defined.  It should be a Range object of the comment's associated cell.  Without that, it is very difficult to do useful work. For instance iterating over ActiveSheet.Comments becomes useless, as you can't where the comments are or what cell contents each relates to. Same behavior on 5.2.5.1 and 5.3.0.3

Steps to Reproduce:
1. have a worksheet with one or more comments.  
2. get a comment object - eg: comment = ActiveSheet.Comments(1) 
3. MsgBox typeName(comment.Parent)

Actual Results:  
"Nothing"

Expected Results:
"Range"


Reproducible: Always

User Profile Reset: No

Additional Info:
Further example: ActiveSheet.Comments(1).Parent.Parent.Name should return the name of the current Sheet.  Looks like Range.Parent isn't wired up either.  I must be doing this wrong.  

"Function CommentFrom(r As Range)" is trivial but "Sub ExtractAllCommentsToTheRight()" is impossible.


User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Comment 1 Xisco Faulí 2017-03-02 11:00:49 UTC
Hello Aaron,

Thank you for reporting the bug. Please attach a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' once the requested document is provided.
(Please note that the attachment will be public, remove any sensitive information before attaching it. 
See https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F for help on how to do so.)
Comment 2 Aaron J. Peterson 2017-03-02 11:39:26 UTC
It's not a bug with a document or my setup.  There simply isn't a Parent property on comment objects, and there should be one.  Are you looking for examples of why this should be?  There are a ton of uses - http://dmcritchie.mvps.org/excel/ccomment.htm has a boatload.  Here's a simple one:


Sub DelComments()
    Dim cm As Comment
    Dim ws As Worksheet
    
    For Each ws In Worksheets
        ws.Activate
        For Each cm In ActiveSheet.Comments
            cm.Delete
            cm.Parent.AddComment Text:="Comment is deleted."
        Next cm
    Next ws
End Sub


(from https://www.mrexcel.com/forum/excel-questions/539902-visual-basic-applications-parent-comment.html)

This fails because cm.Parent, which should be the parent cell Range object, is Nothing.  You'll get this error on that line:

BASIC runtime error.
'91'
Object variable not set.

I'll make up a file with that script and a spreadsheet with a comment if you think need it.
Comment 3 Buovjaga 2017-03-04 18:49:38 UTC
Eike: what do you think?