I am trying to increase Zoom for my Excel Online file using my Add-In. I am using the below javascript code but getting error as "GeneralException: An internal error has occurred."
Please advise where am I going wrong. Online tutorials not much of help with this generic error.
Excel.run(function (context) {
const worksheets = context.workbook.worksheets;
const worksheet = worksheets.getActiveWorksheet();
if (worksheet) {
return context.sync()
.then(function () {
worksheet.pageLayout.zoom = { scale: 200 };
});
}
}).catch(function (error) {
$('#txtcount').val(error);
console.error(error);
if (error instanceof OfficeExtension.Error) {
console.error("Debug info: " + JSON.stringify(error.debugInfo));
$('#txtcount2').val("Debug info: " + JSON.stringify(error.debugInfo));
}
});
After do some investigation, I think the API works well. I think the issue may cause by some "async" issue. Below is the code can work, please try it:
Feel free to contact me if you have other questions.