Why this command doesn't work on Excel Scripts (TypeScript)?

Fedix 0 Reputation points
2024-03-29T17:09:55.01+00:00

Hello all,

I would like to know why this command doesn't work at all.

I've tried every platform (Online and Offline Software) and this command doesn't work either, also if I'm trying to record this, Excel shows up with an error: "Unable to record this action".

This is the standard script that comes from Excel when I'm trying to share this action:

 let selectedSheet = workbook.getActiveWorksheet();

    // Sort the range range G4:L4 on selectedSheet

    selectedSheet.getRange("G4:L4").getSort().apply([{ key: 0, ascending: false }], false, true, ExcelScript.SortOrientation.rows);

It seems the SortOrientation by Row doesn't ever be applied.

In addition, I tried to ask this question in the Microsoft community but I was redirected here.

Also, I tried the two workaround suggested:

You may try changing the range being sorted to a larger range, such as "G4:L10", to see if the issue persists. Additionally, you can try using the SortFields object to specify the sort order instead of passing an array of objects to the apply method.

Unfortunately, still doesn't work.

Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Install, redeem, activate | For business | Windows
Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.