I'm working with Office Add-ins in VS and trying to get a worksheets codename. Every example I've found only uses the text name of a worksheet. Is there a way to find/use the codename?
Asked
Active
Viewed 84 times
1 Answers
2
If I understand correctly, I guess you are asking for the id? You could get the worksheet.id by the following code sample
async function getActiveWorksheet() {
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getActiveWorksheet();
sheet.load("name");
sheet.load("id");
await context.sync();
console.log("The active worksheet :" + sheet.name + " and sheet Id :" +sheet.id);
});
}
The document can be found at https://learn.microsoft.com/zh-cn/javascript/api/excel/excel.worksheet?view=excel-js-preview#id

Raymond Lu
- 2,178
- 1
- 6
- 19
-
That is exactly what I'm looking for, thank you Raymond! In VBA it's called a 'codename'. Very different going from VBA to JavaScript. – Zack Barresse Mar 18 '20 at 14:13