Questions tagged [office-scripts]

Office Scripts is a feature that allows you to automate tasks in Microsoft Office using TypeScript. Currently, this feature is only supported in Excel. Use this tag to ask programming questions about Office Scripts, and consider adding the related tags Excel and TypeScript where relevant.

Office Scripts is a feature that allows you to automate tasks in Microsoft Office using TypeScript.

Currently, this feature is only supported in Excel.

Office Scripts can be created either by using a macro recorder, or by manually writing the script.

Office Scripts contrast themselves from VBA by being usable in Office Online, being primarily asynchronous (while VBA is nearly always synchronous), and lacking support for events. Office Scripts also cannot work with local files and programs.

The documentation is available here: https://learn.microsoft.com/en-us/office/dev/scripts/

Office Scripts use a subset of the Excel JavaScript API, the documentation for that can be found here: https://learn.microsoft.com/en-us/office/dev/add-ins/reference/overview/excel-add-ins-reference-overview

314 questions
1
vote
1 answer

Incrementing Alphabet Counter for Excel Online in Office Script

Context We have data that is exported from elsewhere that we need to process on a regular basis automatically, but we've no control over how it is exported and it comes out in an unsightly and difficult to use manner. So we automated a script which…
Obahar
  • 107
  • 1
  • 1
  • 10
1
vote
1 answer

Excel Office Script to FillDown

Was wondering if there is a way to write excel office script to fill down values in excel sheet. Similar to what we achieve using 'go to special' in the legacy excel Or if we can convert below VBA to excel office script. Sub FillDown() For each…
1
vote
1 answer

Create new workbook from office script

I would like to create a new excel workbook from office script. Is it possible to create a new workbook and give it a dynamic name (date) in office script itself?
Xin Yi
  • 11
  • 3
1
vote
1 answer

Logging to console whenever a cell value exceeds character limit

I have this pseudocode in mind to log an error whenever the length of a cell value within the ItemNumber column exceeds 10 characters. I would also like to display the offending row number as well. Haven't got a chance to test this out fully, but is…
nouptime
  • 9,929
  • 5
  • 22
  • 37
1
vote
3 answers

Office Script "Delete All Rows Except The First Header Row" in Excel

I Try to create a office script, that do the same as this excel makro: Sub clear() Rows("2:" & Rows.Count).ClearContents End Sub my office Script looks like this: function main(workbook: ExcelScript.Workbook) { let table =…
du7ri
  • 67
  • 1
  • 10
1
vote
2 answers

Office Scripts Excel - Set Transparency for bubble chart markers

I am creating a bubble chart in the online Version of MS Excel with the Automate -> Code Editor Typescript language. I am trying to set the transparency for the markers in a bubble chart but I cannot figure it out and I couldn't find any info in the…
robrados
  • 144
  • 10
1
vote
1 answer

custom function in office script?

In Excel VBA I created the below custom function. Is it possible to replicate that in Excel script? Function ColorSum(myrange As Range, mycolorindex As Integer) As Double Dim c As Range On Error Resume Next For Each c In myrange.Cells …
exceldude2001
  • 141
  • 2
  • 2
  • 13
1
vote
1 answer

Power Automate: Copy Excel OneDrive table to the bottom of another Excel OneDrive table

I am currently stuck trying to figure out how to copy all data from a OneDrive excel table to another OneDrive excel table. Simply paste data to the bottom of the table. Both tables have the same amount of columns and data types. Copy table from an…
Elixir
  • 303
  • 3
  • 9
  • 26
1
vote
2 answers

Call Function via User Interaction with Office Scripts in Excel Online

Is it possible to trigger an Office Scripts function within Excel Online as a result of a user action? For example, can I run a specific Office Scripts function when the user clicks on a hyperlink within Excel Online? If so, can you give an…
1
vote
1 answer

How to automate pivot table filtering with Office Scripts?

i'm trying to rebuild some VBA-Code in Office-Scripts, because I want to automate the execution via Microsoft Power Automate (former Flow). Now I have problems with a section of my code dealing with pivot tables. In the VBA-Code, i use: Dim…
ediordna
  • 300
  • 2
  • 15
1
vote
1 answer

Unlock individual cells before protect sheet

There's another question addressing how to protect the sheet but doesn't show how to unlock individual cells. I can't just start recording & create a script (which usually show how it's done) because apparently, excel online still doesn't support…
rrh
  • 808
  • 7
  • 12
1
vote
2 answers

How to Clear Table Style in Office Scripts?

How can I clear the styles on a table? I tried recording the macro but when I record it and run it, it will say failed (Table setPredefinedTableStyle: The argument is invalid or missing or has an incorrect format.). function main(workbook:…
Ethan
  • 808
  • 3
  • 21
1
vote
3 answers

API call via Office scripts in MS Excel WebApp

In the Excel WebApp (Office 365) it is possible to place Office Scripts via the "Automate" tab, which is using the JavaScript-syntax and which could automate excel like a VBA-macro, but for the excel WebApp (Screenshot). How is it possible to add…
Peter
  • 323
  • 4
  • 15
1
vote
1 answer

How can I make this office script faster?

how could I make this recursive script faster? RNumber in this code is calculated in the spreadsheet through a formula and checked after each iteration I'm typically iterating down from numbers > 50000 and the script runs very very slow. As a result…
Jai Hirani
  • 99
  • 9
1
vote
1 answer

Currrently Javascript API avalaible to all Excel versions

Please, is there a way to access the currently javascript API available independently of which Excel version I have??? At the moment only E3 or E5 licenses have this access and the ScriptLab still works with an older API. Thanks in advance!