Share via

Office.extensionLifeCycle.taskpane.setWidth() doesn't work on Web Word

Roman Tremb 20 Reputation points
2026-02-23T09:58:52.6966667+00:00

Hello!

I'm trying to use Office.extensionLifeCycle.taskpane.setWidth() to install initial width of my addin's taskpane like this:

Office.onReady(() => {
	
tr
    console.log(Office.context.requirements.isSetSupported('TaskPaneApi', '1.1'));
    Office.extensionLifeCycle.taskpane.setWidth(480);
    console.warn("====Task pane width set to 480px");
  } catch (e) {
    console.warn("====Could not set task pane width", e);
  }
});

This code perfectly works for Desktop Word, but doesn't work at all for Web version. No issues occured.

Build: 20260218.2

The addin is hosted by dev mode using office-addin-debugging

Browser: Chrome ``145.0.7632.109

Microsoft 365 and Office | Development | Office JavaScript API
0 comments No comments
{count} votes

Answer accepted by question author
  1. Gabriel-N 14,775 Reputation points Microsoft External Staff Moderator
    2026-02-23T12:41:16.6966667+00:00

    Hello Roman Tremb

    Thank you for reaching out to the Q&A forum and sharing your question with us.

    I tested the code you provided in my own environment, and it actually works well. However, I want to clarify that my testing was not done through a sideloaded add-in using office-addin-debugging. Instead, I tested the exact same logic directly inside the ScriptLab add-in on both Word Desktop and Word on the web, and the API behaved as expected there.

    Because of that, it’s possible the behavior difference you’re seeing is due to environment differences (for example: sideload dev mode, hosting frame timing, or WebView environment). I can’t say for sure without fully replicating your exact dev setup, but it’s a possible factor.

    I also added a quick test for: Office.context.requirements.isSetSupported('TaskPaneApi', '1.1');

    and tried wrapping setWidth(480) with a small setTimeout() just to confirm whether timing affects behavior. In my tests, both worked normally.

    Additionally, I noticed in your snippet there is a small typo: you have "tr" at the beginning, I assume that was supposed to be "try".

    It’s also possible that in your actual project there may be additional logic surrounding that block that could influence when or how setWidth() gets called.

    Since this might be related to a specific environment or a recent regression, I recommend also asking on the OfficeDev GitHub for better investigation.


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

    1 person found this answer helpful.

0 additional answers

Sort by: Most 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.