Forum Discussion
LearnExcelScript
Sep 27, 2023Copper Contributor
Problem ExcelScript in excel files with compatibility mode 97-2003
I don't really know if this is the problem, but after many times of trying to run the most simple lines of code in Excel Typescript,
function main(workbook: ExcelScript.Workbook) {
const sheet = workbook.getActiveWorksheet();
let range = sheet.getUsedRange();
const table = sheet.addTable(range, true);
}
it would always show "Error - Worksheet getUsedRange: There was an internal error while processing the request".
But when I copy paste the entire sheet (ctrl + A) into a new excel workbook (excel latest version), the code obviously is coerced. The only conclusion I arrived to is that excel ExcelScript wont run on files labeled as "compatibility mode Microsoft excel 97-2003"
Can someone please confirm/challenge this assumption?
Thanks beforehand!
LearnExcelScript I hoped to find an answer here:
https://learn.microsoft.com/en-us/office/dev/scripts/testing/platform-limits
but it does not mention the Excel file type.
- MichelleRanMSFT
Microsoft
Hi LearnExcelScript, thanks for your question! Office Scripts should be supported in .xls files as long as you open them in a recent Excel client. It's possible there are other issues with your workbook that prevent the script from working properly. Could you share a session id and/or a sample workbook (sensitive data removed as needed)?
- JKPieterseSilver Contributor
MichelleRanMSFT Thank you for jumping in!
- MichelleRanMSFT
Microsoft
Ah, I see - there does indeed appear to be a bug with the getUsedRange API when run on workbooks in compatibility mode. We've logged a bug with the relevant team, although we don't have a timeline to share at the moment. Thanks for reporting this!
- JKPieterseSilver Contributor
LearnExcelScript I hoped to find an answer here:
https://learn.microsoft.com/en-us/office/dev/scripts/testing/platform-limits
but it does not mention the Excel file type.