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

Run Excel Solver using Office Scripts (not VBA)

I need to automate a simple pipeline which runs the Excel Solver. I'd like to use Office Scripts (TypeScript https://learn.microsoft.com/en-us/javascript/api/office-scripts/overview?view=office-scripts). I've written a VBA script which works, but…
mherzog
  • 1,085
  • 1
  • 12
  • 24
1
vote
2 answers

Office Scripts - How to select specific columns using column name from a table and delete other columns?

I want to select specific columns by Column Name from a table in Excel Online Workbook and delete other unwanted columns. I want to do this using Office…
Kavinda
  • 13
  • 1
  • 3
1
vote
2 answers

How to loop through cell in table column and check if Regex pattern has match?

i am trying to write Office Script to loop through table column range and check if Regex PAttern has match. If yes just mark red color: function main(workbook: ExcelScript.Workbook) { let worksheet = workbook.getWorksheet("Workstreams"); …
1
vote
1 answer

Office script to get sheet names and populate them in a column

I've been using a VBA script to get all the sheet names in a worksheet and put them in a column. It works fine but we need to migrate to the online version and it doesn't support VBA at all. Could you help me out? Here's the original VBA…
Bnikushev
  • 35
  • 4
1
vote
1 answer

Using a variable in a formula to refer to the last row in Office Scripts

Using Office Scripts (in Excel), I'd like to apply a formula to a new column in which the formula contains the function for finding the maximum value of an adjacent column. The number of data points collected varies from experiment to experiment, so…
Audrey
  • 13
  • 3
1
vote
1 answer

How to write Office Script equivalent data validation dropdown list?

I searched the official documentation, found this formula ExcelScript.ListDataValidation, but i have no clue how to use it. tried writing this way but no help. Anyone knows how to use this function? let selectedSheet =…
1
vote
0 answers

Failed to fetch in Excel Office Web Script

I'm getting a Line 15: Failed to fetch error without further details. This is my script in Excel Web. async function main(workbook: ExcelScript.Workbook) { let sheet = workbook.getActiveWorksheet(); const company:string =…
Kay B
  • 11
  • 2
1
vote
1 answer

OfficeScripts to delete visible rows after filtering

Good Day!! Have a data dump that comes from one of my systems into excel. The size of the data can vary from 200 rows to 250,000 rows. So to avoid some load restrictions, I have found the best way to manipulate/clean this data is avoid creating a…
RustyMc
  • 29
  • 1
  • 6
1
vote
1 answer

Power Automate Convert File from CSV to XLSX

Good Day!! Got a problem in Power Automate that I have played with for days now... With that, I am a hobby programmer and an accountant by day. I am attempting to use MS Power Automate to grab a CSV file from an SFTP site and save it to my…
RustyMc
  • 29
  • 1
  • 6
1
vote
2 answers

Get workbook url from office scripts api

Hopefully a rather simple one but I cannot work out how to get the URL or full path (fullname) for the workbook. The workbook is https://example.sharepoint.com/sites/abc/x/y/z/file.xlsx How do I get this path out of office script api
mfaiz
  • 475
  • 1
  • 7
  • 17
1
vote
1 answer

How can I do step by step debugging, or even set break point in Excel 365 Office Scirpt code?

I have enabled Office Script, and I see AUTOMATE tab in my Excel-365. I can write a script and also see results in log and on sheet . But when I see the tab, or the script, I do NOT see any way to take step by step execution, or even set a…
1
vote
2 answers

Office Scripts Delete Entire Rows Based on Multiple Data in Certain Cells

I am a non-programmer and quite new to Office Scripts and I would love some help. I am currently trying to delete entire rows if the cell in the "Change Flag" column, which happens to be the second column on the Excel sheet, contains the word…
1
vote
1 answer

Pass multiple Excel cell values to Power Automate

I'm using Office Scripts to pass an Excel cell value stored in SharePoint to Power Automate. It works great for one cell, but I can't figure out how to pass multiple cell values. Here's my current Office Script that gets the value in cell B3. When I…
Robby
  • 843
  • 3
  • 19
  • 53
1
vote
2 answers

Getting an Image of a Power Pivot including Conditional formatting and send email

I'm trying to use the combination of Excel Office Script and Power Automate to send email with an image of Pivot Table. Below is the code I came up with, but the resulting image that gets sent doesn't include the conditional formatting, only the…
Nico
  • 15
  • 4
1
vote
1 answer

TypeScript/Office Scripts - Sum the Values of A Cell Based on The Values of An Another cell

I am recently experimenting with Office Scripts and TypeScript and I have encountered the following problem. I have an Excel file that contains the following data: calendar weeks -> eg. CW1 = calendar week1, CW2 = calendar week 2 etc the values for…
Mateusz Woś
  • 333
  • 2
  • 10