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.
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.
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.
Unshare a script
You can unshare any script in a workbook that you have open for editing. Note that if you unshare a script that you don't own, you cannot add it back - the owner of the script will have to do so if it is necessary.
Click the script in the script gallery.
On the Code Editor menu, select Stop sharing.
In the Stop sharing in this workbook dialog, if you own the script, you can select Stop sharing in all workbooks - but be sure you want to, because this can't be undone. To reshare the script, you'll have to share it in each workbook again. When you are ready, select Stop Sharing.
Note: 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.
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.