Error: Associate script with workbook

Nikhil Narayanan 0 Reputation points
2026-09-16T00:17:42.59+00:00

Hello,

I have created an Office Script in Excel for the web and stored the workbook in OneDrive. The script runs successfully when I execute it manually from the Automate tab.

My goal is to associate the script with the workbook and create a worksheet button so other users with access to the workbook can run the script themselves. According to Microsoft's documentation, this should be done by enabling Associate with workbook and selecting Add button to worksheet.

However, when I attempt to associate the script with the workbook, Excel displays the error:"Oops, something went wrong"

I have already tried basic troubleshooting steps (refreshing Excel, reopening the workbook, using different browsers, confirming the workbook is stored in OneDrive, and verifying the script runs manually), but the issue persists.

Any help on this would be great.

Kind regards

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments

2 answers

Sort by: Oldest
  1. AI answer

    2026-09-16T00:18:03.3+00:00

    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:

    1. 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.
    2. 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.
    3. 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.
    4. 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.
    5. 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.
    6. 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.
    7. 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.
    8. 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

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

    1 person found this answer helpful.
  2. Kien 1,625 Reputation points Independent Advisor
    2026-09-16T00:55:38.3866667+00:00

    Dear Nikhil Narayanan,

    Based on your description, kindly try these steps:

    Enable third-party cookies for Excel for the web. Office Scripts requires third-party cookies in the browser. If your browser blocks them, allow third-party cookies for Microsoft 365, OneDrive, and Excel sites, then reopen the workbook in a new browser window.

    Have the Microsoft 365 administrator check script sharing. In the Home - Microsoft 365 Apps admin center > Customization > Policy Management.

    Open the policy configuration assigned to the affected user, or create one for a test group.

    Search the policy settings and verify that these policies are enabled:

    • Let users automate their tasks in Excel
    • Let users with access to Office Scripts share their scripts with others in the organization

    User's image

    Confirm that the policy configuration is assigned to the affected user or a group containing that user.

    The second policy is the relevant one for Associate with workbook, because associating a script shares it with workbook editors in the same organization.

    Retest with a clean workbook. Create a blank workbook directly in your organizational OneDrive, create a simple new script in that workbook, and try Associate with workbook. If this works, the issue is isolated to the original workbook or script rather than the tenant configuration.

    Recreate the script if needed. From the affected script’s menu, select Make a copy, open the copied script while the target workbook is active, and try Associate with workbook again. Copying is a supported script action and helps remove a broken script-to-file sharing reference.

    Once association succeeds, select Add button to worksheet. This associates and shares the script with anyone in the organization who has permission to edit the workbook. Users with only view access cannot run the linked script.

    Note: If the administrator recently changed the Office Scripts settings, the change can take up to 48 hours to take effect. Issues related to Office Scripts | Microsoft Learn

    I hope the information shared helps point you in the right direction.  


    If the answer is helpful, please click "Yes" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in the forum documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.