Office Scripts can be shared with other users of an Excel workbook. When you share a script in a workbook, you attach the script to the workbook, enabling other to view and run it.
Important: Anyone who can edit a workbook can view and run its attached scripts.
Note: This feature is only available to Microsoft 365 subscribers who have joined the Office Insider program. If you are a Microsoft 365 subscriber, make sure you have the latest version of Office.
Share your script in a workbook
You can use a script's Details page to share the script in a workbook. Your scripts are stored in your OneDrive, and when you share one, you create a link to it in the workbook you have open.
-
On the Automate tab, in the script gallery, select the script you want to share. Note that you can only share your own scripts - any other scripts you see in the gallery are already shared in the workbook you have open.
The Code Editor opens and displays the script you selected.
-
On the Code Editor menu, select Share.
-
Note the message about who can use the shared script, and select Share to proceed. In the script gallery, the script you shared now has a different icon, indicating it has been shared in the workbook and therefore can be run by anyone who can edit the 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 will automatically be 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.
-
You can also share a script by creating a button. For more information, see Create a button to run an Office Script.
Allow a shared script to run
The first time you run a script you don't own in a workbook, the Run Permission dialog box opens and asks whether to allow the script to view and edit the workbook. If you trust the author of the script, click Allow.
See Also
Introduction to Office Scripts in Excel