Using below code to identify worksheet rename event and perform activity after rename. Same is working fine in online version of excel(online office365) on Chrome/edge browser but its not working on desktop version of excel(Microsoft 365 MSO (16.0.14326.21170) - 32-bit).
export const onSheetNameChange = event => {
Excel.run(context => {
return context.sync().then(() => {
const { nameAfter, nameBefore } = event;
if (nameBefore !== nameAfter) {
console.log('nameBefore=>', nameBefore);
console.log('nameAfter=>', nameAfter);
}
});
});
};
export const onSheetRenameHandler = () => {
Excel.run(context => {
const sheets = context.workbook.worksheets;
sheets.onNameChanged.add(onSheetNameChange);
return context.sync().then(() => {
console.log(
'A handler has been registered for the OnNameChanged event.',
);
});
});
};
Followed this documentation link to implement same.
Could see this error in console: Uncaught (in promise) RichApi.Error: You cannot perform the requested operation. at new n (excel-win32-16.01.js:25:241192) at i.processRequestExecutorResponseMessage (excel-win32-16.01.js:25:305358) at excel-win32-16.01.js:25:303421
ActionIndex: Code: "AccessDenied" HttpStatusCode: 403 Location: "WorksheetCollection._RegisterEventNameChanged" Message: "You cannot perform the requested operation."
Can someone please let me know "onNameChanged" event supports desktop excel and its released to use? Please help if I am missing anything. Thanks in advance!