Share via

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

Anonymous
2024-03-29T15:05:51+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 selectedSheetselectedSheet.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.

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-03-29T16:03:37+00:00

    It is possible that the issue is with the range being sorted.

    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.

    I'd suggest you create a new thread in Office development which is special channel to handle Office Script issue.

    Office Development - Microsoft Q&A

    Thank you for your understanding.

    Was this answer helpful?

    0 comments No comments