Excel Add In Can't Add Comments - This operation is not implemented.

Arnav Garg 0 Reputation points
2024-06-24T20:40:03.5366667+00:00

I'm currently on MacOS Sonoma (14.5) using Office16.86 (appears to be as updated as possible) building an Excel add in. I am trying to programatically add a comment to Excel on a specific cell through taskpane.js.

However, every time I try to add this comment, I get "This operation is not implemented." I am using the below code:

  Excel.run(async context => {
    const range = context.workbook.getSelectedRange();
    
    let comments = context.workbook.comments;
    comments.add(range, "TODO: add data.");

    await context.sync();
    logMessage('Comment inserted into Excel');
  }).catch(error => {
    logMessage(`Error inserting comment into Excel: ${error.message}`);
  });
}



Does anyone have any suggestions on how to do it?

Alternatively, my whole use case is I just want to store meta information about the cell and the best way I could think of doing it was through a comment, but do cells have metadata (or something similar) that I can access programatically to store/retrieve the meta information?

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
1,673 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,700 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yue Li 0 Reputation points Microsoft Employee
    2024-07-02T07:54:29.4+00:00

    Hi Arnav, I'm running your code on my machine and it's working fine. My MacOS Sonoma version is same with you, but using Office16.87. Maybe you can update your Office version and try it again. Thanks! :)

    However, it is important to note that a Range parameter can only be a single cell. Here is the document link: https://learn.microsoft.com/en-us/javascript/api/excel/excel.commentcollection?view=excel-js-preview#excel-excel-commentcollection-add-member(2) Hope it helps you!

    User's imageUser's image

    User's image

    0 comments No comments