A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
The failure is most likely in the workbook-association step, not in the script itself, since the script already runs from Automate.
Check these conditions in order:
- Confirm the script is opened from Automate > View Scripts Open the script details page, then scroll to Share this script. The workbook button can only be created from there by enabling Associate with workbook and selecting Add button to worksheet.
- Verify the workbook is in a supported cloud location Office Scripts are stored in OneDrive, and associating a script creates a link between the script and the current workbook. This feature is intended for cloud-backed workbooks and scripts.
- Confirm write access for the workbook users Everyone with write permissions to the workbook can use the associated script. If the workbook is shared read-only for some users, they won’t be able to use the shared automation as intended.
- Check whether OneDrive sharing is restricted by organizational policy If OneDrive sharing is restricted by organizational policies, Excel cannot associate a script with a workbook or create a script button. This is a documented blocker for the exact feature being used.
- Check Office Scripts availability in the tenant If the Automate experience is partially available but workbook association fails, verify that Office Scripts has not been disabled by the Microsoft 365 admin center or blocked by policy.
- Check Conditional Access restrictions Conditional Access can block access to scripts stored in OneDrive or SharePoint, especially from unmanaged devices. If the tenant uses authentication context settings with Conditional Access, Office Scripts in Excel on the web are not supported. In that case, use Excel for Windows or Excel for Mac instead.
- If the script was previously associated, remove and recreate the association In the script details page, disable Associate with workbook if it is enabled, confirm removal, then reopen the workbook and create the association again. Deleting a button from the sheet alone does not remove the workbook association.
- If the button is created later but does not run for some users The first time someone runs a script they do not own, Excel shows a Run Permissions dialog. They must select Allow.
Important limitations to keep in mind:
- Script buttons are not available during the Office Scripts preview for personal and family Microsoft 365 subscriptions.
- If the workbook is opened in an older Excel version that does not support Office Scripts, the button may appear but selecting it does nothing.
For this specific error pattern—manual run works, but Associate with workbook fails—the strongest documented causes are:
- OneDrive sharing restricted by organizational policies
- Office Scripts disabled or blocked by admin/policy
- Conditional Access restrictions affecting OneDrive/SharePoint script access