Sharing Office Scripts in Excel
Applies To
Office Scripts can be shared with other users in your organization. When you share a script, you associate that script with the current workbook. This enables other users in your organization to view and run it.
Important: Anyone who can edit a workbook can view and run its linked scripts.
Share and unshare your script in a workbook
Your scripts are stored in your OneDrive. When you share a script, you create a link between the script and the workbook you have open.
To share a script, take the following steps.
-
On the Automate tab, select the script you want to share from the Office Scripts Gallery by selecting View Scripts .
Note: You can only share your own scripts. You might have access to other scripts that have been shared with you or built-in sample scripts that can't be shared.
The Office Scripts task pane opens and displays the script you selected. -
Scroll to the Share this script section. Toggle Associate with workbook to link the script to your current workbook.
Notes:
-
Shared scripts can be run by any user with write permissions to the workbook. Anything changed by the script is recorded as an edit by the person running the script, not the script's owner.
-
Any updates you make to a shared script are automatically shared with others. The script is updated when you save it. People using your script may need to reopen it if they have an old version open when you make a change.
-
An Office Script can only be shared within your organization. Scripts can't be shared to external users.
-
-
Select the Add button to worksheet to add a button to your worksheet that triggers the script.
-
To view scripts associated with a worbook, go to This workbook in the Office Scripts task pane.
-
Toggle Associate with workbook to the off position to stop sharing a script with that workbook.
Important: Deleting a script button from the workbook won't toggle Associate with workbook to the off position or remove that script from the This workbook list in the Office Scripts task pane.
Tip: To share your script with a specific person instead of sharing it in the workbook, go to your OneDrive > Documents > Office Scripts folder, and share the script file .
Save Office Scripts on a SharePoint site
Save Office Scripts on SharePoint to share them with your team. When you save a script to SharePoint, anyone with access to the SharePoint can view, edit, or run the script.
Move a script to SharePoint
Follow these steps to change where a script is stored.
-
On the Automate tab, select the script you want to share from the gallery or select View Scripts to open the Office Scripts task pane.
-
Select the ... menu and then select Move script. This opens a file picker where you can select folders in your SharePoint site. Saving to a new location moves the script to that location.
Notes:
-
Moving a script can take up to a minute.
-
Moving a script breaks the share links and flows currently associated with it. If there are any links that could be associated with the script, a warning message appears. The warning message doesn't always mean breakage will occur, only that one is possible.
Allow a shared script to run
The first time you run a script that you don't own, the Run Permissions dialog box opens. This asks whether to allow the script to view and edit the workbook. If you trust the author of the script, select Allow.
Note: The Run Permissions dialog also opens whenever the script is updated by another colleague in your organization.
Requirements
An active Microsoft 365 subscription account with a commercial or educational Microsoft 365 license that has access to the Microsoft 365 Office desktop apps. This includes:
-
Microsoft 365 Apps for business
-
Microsoft 365 Business Standard
-
Microsoft 365 Apps for enterprise
-
Office 365 ProPlus for Devices
-
Office 365 A3
-
Office 365 A5
-
Office 365 Enterprise E1
-
Office 365 Enterprise E3
-
Office 365 Enterprise E5
-
Office 365 F3
-
Server authentication - When first running the Script Recorder or Code Editor, you need to authenticate with the server, so your scripts can be saved to the cloud. Sign-in to your Microsoft account as usual, then when you see the Permissions requested prompt, choose Accept to continue.
Note: Once you've toggled on the correct setting in the admin center, end users with the appropriate license can access the feature. This feature is not yet available in Microsoft 365 for US Government and customers with data residency in one of the new local datacenter geos .
See also
Introduction to Office Scripts in Excel