logo
search
Chart & Visualization Issues

Fix Excel Office Scripts Error for Doughnut Chart Data Labels

Algirdas JasaitisAlgirdas Jasaitis Oct 19, 2026 868 views

Question details

The user needs to fix an error encountered when setting the data label position for a doughnut chart using Office Scripts.

Fix Office Scripts Error When Setting Doughnut Chart Data Label Position
Product
Microsoft Excel
Device & OS
not provided
Scenario
Automating chart formatting and data label positioning using the Office Scripts API in Excel.
Observed behavior
Executing chart.getDataLabels().setPosition() returns the error "This operation is not permitted for the current object" because the requested position is unsupported for doughnut charts.
Before you start

Ensure you have saved your workbook and verify the exact chart type you are targeting, as different chart types support different data label parameters in the Office Scripts API.

Solution 1Recommended

Use Supported Label Positions or Format Manually

Modify your script to use a universally supported data label position, or bypass the API limitation by formatting the chart manually.

Doughnut charts have specific structural limitations in Excel. Certain data label positions, such as 'Callout' or 'OutsideEnd', may not be supported through the current Office Scripts API.

To resolve the "operation is not permitted" error, you must request a supported ChartDataLabelPosition or apply the desired formatting manually.

1
Locate the problematic script line

Open the Code Editor in Excel and find the line containing chart.getDataLabels().setPosition() in your Office Script.

2
Change the position parameter

Update the requested position parameter to a standard option that is supported for doughnut charts, such as 'Center' or 'BestFit'.

3
Run the script

Execute the script again to confirm that the "operation is not permitted" error is resolved and the labels update successfully.

4
Apply formatting manually (Alternative)

If your project strictly requires callouts that the API rejects, click on the doughnut chart in Excel, click the '+' Chart Elements icon, select 'Data Labels', and format them manually via the Format Data Labels pane.

Use Supported Label Positions or Format Manually
API Limitations: Microsoft continuously updates the Office Scripts API. If you need a specific unsupported layout, you may need to rely on manual formatting until the API adds full support for doughnut chart callouts.
Free Microsoft Office alternative

Try WPS Office for Seamless Chart Formatting

If complex scripting errors and API limitations in Microsoft Excel are slowing down your workflow, WPS Office offers a highly compatible, user-friendly alternative. Enjoy intuitive built-in chart formatting without the steep learning curve of automation scripts.

  1. 1. Open your data in WPS Spreadsheets: Launch WPS Office and open your existing Excel workbook containing the chart data.
  2. 2. Insert a Doughnut Chart: Select your data range, navigate to the Insert tab, click the Chart icon, and choose the Doughnut Chart layout.
  3. 3. Customize Data Labels intuitively: Right-click the chart and select 'Add Data Labels'. Use the straightforward formatting pane to easily position them as callouts or centers without writing a single line of code.
Fully compatible with Microsoft Excel (.xlsx, .xls, .csv) file formats.Easily create and customize complex charts, including doughnut charts with rich data labels.Lightweight architecture ensures smooth performance even with large datasets.Free to download and use, offering a familiar interface for quick migration.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Excel throw an error when I set doughnut chart data labels via Office Scripts?

This happens because the specific label position you are trying to apply (like 'Callout') is not supported for doughnut charts through the Office Scripts API. Calling an unsupported configuration triggers the "operation is not permitted" error.

Can I use VBA instead of Office Scripts to set data label positions?

Yes. VBA utilizes a different, older object model that sometimes offers more flexibility than the newer Office Scripts API. You can experiment with the DataLabels.Position property in a VBA macro to see if it allows your desired layout.

Which data label positions are universally supported for doughnut charts in Excel?

Generally, simple positions like 'Center' or 'BestFit' are supported. Complex positions like 'OutsideEnd' or detailed data callouts are often restricted on doughnut and pie charts depending on the exact API version.