Skip to main content

How to Save an Office Script to SharePoint

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

A new Office Script lives in your own OneDrive, so it stops working for everyone else the day your account goes. Saved in a SharePoint folder, it belongs to the team: anyone who can open that folder can run it, and Power Automate can run it from there too.

The example moves Say Hello, the script from How to Create and Run an Office Script in Excel, into a Scripts folder in the Documents library of a SharePoint site called Communication site (How to Create a Folder in a SharePoint Document Library).

Microsoft's Office Scripts file storage and ownership explains the difference: scripts are saved in /Documents/Office Scripts/ in your OneDrive by default, and Office Scripts that are saved to a SharePoint site are owned by your team.

Prerequisites​

  • Permission to add files to the SharePoint folder, such as membership of the site's Members group.

Step 1: Open the Script's Menu​

In Excel for the web, select Automate, View Scripts. On the script's card, select ... (More options), then Move script:

The Office Scripts pane filtered to Say Hello, with the card's menu open: Run, Edit, Delete, Rename, Make a copy, Move script outlined in red, Add in workbook and Automate a task

Make a copy is a different command: it leaves the script where it is and makes a second one. Microsoft's article describes the same move from the Code Editor, with a Move button that appears when you select the script's name; in my Code Editor that button wasn't there, and the card's Move script did the job.

Step 2: Choose the Folder​

A file picker opens. It starts in your OneDrive: select More places..., choose the site, then the library and the folder. Here that's Communication site, Documents, Scripts. Select Save:

The file picker at Communication site, Documents, Scripts, an empty folder with We didn't find anything to show here, and the Save button outlined in red

Step 3: Check Where It Went​

Excel says Script moved successfully., and a cloud appears at the bottom left of the card:

The Office Scripts pane with the message Script moved successfully. above the Say Hello card, which now has a cloud icon next to Edit, Rename and Run

Select the script's name to open its details. Under the name, and in File path, it now says Shared Documents » Scripts. Shared Documents is the address of the library that's called Documents:

The script's details: Say Hello with Shared Documents » Scripts under the name, the message Script moved successfully., and the Script Information section with Name Say Hello, an empty Description and File path Shared Documents » Scripts

The Result​

In SharePoint, the Scripts folder holds Say Hello.osts:

The Documents library open at the Scripts folder, with one file, Say Hello.osts, modified about a minute ago by Admin User

The script is no longer in your OneDrive's Office Scripts folder. It runs from Excel as before, and Power Automate runs it with Run script from SharePoint library (How to Run an Office Script from a SharePoint Library in Power Automate).

Common Mistakes​

MistakeWhat happensDo this instead
Make a copy instead of Move scriptTwo scripts, and changes to one don't reach the otherMove script
Moving it to a folder people can't openThey can't run itChoose a folder the team can read
Expecting Run script in Power Automate to find itThat action lists only the scripts in your OneDriveRun script from SharePoint library

Troubleshooting​

SymptomLikely causeFix
The script isn't in Recent for someone elseThey haven't opened it yetAll scripts, View more scripts, then pick the .osts file
The move takes a whileMicrosoft says moving can take up to a minuteWait, then check File path
The script stops with a network error after the moveMicrosoft says scripts with external calls can't run from SharePointKeep that script in OneDrive

FAQ​

How do other people open a script from SharePoint?​

Microsoft's article: in All scripts, select View more scripts at the bottom of the list, and pick the .osts file. After that it's in their recent scripts.

Can I move it back?​

Yes: Move script again and choose a folder in your OneDrive.

Which Power Automate action runs it now?​

Microsoft's Excel Online (Business) connector reference says Run script is for a script saved in the default location, your OneDrive, and Run script from SharePoint library for one saved outside of the default location. For a script in SharePoint, use the second, and choose the script in its new place.

Conclusion​

On the script's card, ..., Move script, More places... and a SharePoint folder move an Office Script out of your OneDrive. Its File path shows the new place, and the team, and Power Automate, can run it from there.

Additional Resources​