none
OLE automation and adding comment RRS feed

  • Question

  • Hello,

    in my XLL I want to set a string as cooment to sevral cells at all using OLE automation.

    So I use

    this->xRange->ClearComments();
    this->xRange->AddComment(comment);
    

    Where xRange is Excel::RangePtr and comment is a _variant_t of type VT_BSTR.

    If xRange just adresses $C$7 then the code works,
    but if xRange adresses $C$7:$C$8 then there's an exception at AddComment :

    wrong parameter. (HRESULT=80070057)

    [ClearComments() does work ]

    If comment has value "foo", then C7 should have comment "foo" and C8 should also have comment "foo".

    So how can I achieve this ?

    TIA

      Hendrik Schmieder


    Monday, August 7, 2017 2:16 PM

Answers

  • Hi h_schmieder,

    I could reproduce your issue in VBA and when I try to add a comment to a range with multiple cells manually, it would only insert comment to the cell in the upper-left corner of the range. So I think AddComment method does not support to add comment to multiple cells directly. I suggest you iterate through the cells in the range and add comment to each cell.

    Best Regards,

    Terry

    • Marked as answer by h_schmieder Wednesday, August 9, 2017 12:05 PM
    Tuesday, August 8, 2017 3:19 AM

All replies

  • Hi h_schmieder,

    I could reproduce your issue in VBA and when I try to add a comment to a range with multiple cells manually, it would only insert comment to the cell in the upper-left corner of the range. So I think AddComment method does not support to add comment to multiple cells directly. I suggest you iterate through the cells in the range and add comment to each cell.

    Best Regards,

    Terry

    • Marked as answer by h_schmieder Wednesday, August 9, 2017 12:05 PM
    Tuesday, August 8, 2017 3:19 AM
  • Strange,

    I got a message that somebody answered on this thrread

    but when I open this thread in Windows 7 IE 11 I only see my original post.

    I also doesn't see a logout possibility.


    • Edited by h_schmieder Tuesday, August 8, 2017 1:29 PM forgotten word
    Tuesday, August 8, 2017 1:26 PM
  • Hi h_schmieder,

    Yes, yesterday I got similar issue as you that I could not see my reply. Today, I open this thread in several browsers and all of they could show the reply correctly. I suggest you check the thread again. If you still see the my previous, please feel free to let us know.

    Best Regards,

    Terry

    Wednesday, August 9, 2017 2:09 AM
  • Now,

    I can see áll replies.

    Back to original Problem.

    It Looks like I have to iterate through all cells in the range.

    So I have now to find out how to do this, especially in case the range contains serveral disjunct areas.

      Hendrik

    Wednesday, August 9, 2017 12:05 PM