Skip to Content

Excel cell comments via ole object - get comments in excel sheet

Hi, is it possible to get a comment text of a cell using abap ole object?

I already read this:

https://archive.sap.com/discussions/thread/3777521

but it's addcomment. I want read or get comment.

I tried with

DATA: obj_erange TYPE ole2_object,
obj_ecomment TYPE ole2_object.

* CALL METHOD OF application 'Range' = obj_erange
* EXPORTING
* #1 = 'A1'
* #2 = 'A1'.

CALL METHOD OF worksheet 'Cells' = h_cell
EXPORTING #1 = 1 #2 = 1.
m_message.
CALL METHOD OF worksheet 'Cells' = h_cell1
EXPORTING #1 = 1 #2 = 1.
m_message.

CALL METHOD OF worksheet 'RANGE' = obj_erange
EXPORTING #1 = h_cell #2 = h_cell1.
m_message.

CALL METHOD OF obj_erange 'Select'.

CALL METHOD OF obj_erange 'Comment' = obj_ecomment.

CALL METHOD OF obj_ecomment 'COPY'.

CALL METHOD cl_gui_frontend_services=>clipboard_import
IMPORTING
data = excel_tab
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.

But, it was not work.

Please, let me know.

I searched at

https://docs.microsoft.com/

but, I couldn't find solution.

CALL METHOD OF obj_erange 'Comment' = obj_ecomment.

This is failed, too.

How can I get comments in worksheet ???

Somebody help me, please !!!!!! OTL

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Feb 11, 2019 at 06:04 AM

    You should explain what means "it doesn't work" (which line of code returns the error code...)

    By using the Excel macros (alt+F11), this VBA code works, just translate it to ABAP:

    Set cell = Cells(1, 2)
    Text = cell.Comment.Text
    

    So, I guess you have 2 main errors :

    1) the worksheet object doesn't have any RANGE method. Anyway you don't need it because CELLS is a range object !

    2) you forget the TEXT property : don't copy the COMMENT object, do :

    DATA comment_text TYPE c LENGTH 255.
    GET PROPERTY OF obj_ecomment 'text' = comment_text.

    PS: you don't need the clipboard too.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.