How to update ribbon state on add‑in load in new Excel windows with fresh workbooks? #6456
Unanswered
Valentin Toea (valentin-toea)
asked this question in
Q&A
Replies: 1 comment
|
Hi, any update on this please? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi! I’m trying to understand the correct pattern for updating custom ribbon button states when the add‑in loads in new Excel windows (i.e., new workbooks created via File -> New).
Scenario
My add-in has a custom ribbon with several buttons disabled by default.
I also have Sign in / Sign out buttons.
After the user signs in, I store auth state in localStorage and use Office.ribbon.requestUpdate to enable the buttons.
*This works perfectly in the first Excel window where the user interacts with the add-in.
When the user opens another Excel window and creates a fresh workbook:
The add-in loads
Office.onReady fires
I can read the existing session from localStorage
I call Office.ribbon.requestUpdate(...) to enable the buttons
…but the ribbon doesn’t actually update until the user clicks any button in it. It feels like the update is queued until the first user interaction.
Notes
When opening saved files, this workflow works fine because I am also using
Office.addin.setStartupBehavior(Office.StartupBehavior.load) and the add‑in is auto‑loaded.
This question is specifically about brand‑new workbooks opened in new Excel windows.
The docs for Office.ribbon.requestUpdate(...) say:
“Note that this API is only to request an update. The actual UI update to the ribbon is controlled by the Office application and hence the exact timing of the ribbon update cannot be determined.”
So I’m wondering if this user‑interaction requirement is expected behavior or a result of a security feature.
Question
Is there a supported way to update ribbon state immediately when an add‑in loads in a brand‑new workbook (in a new Excel window), without waiting for the first user interaction?
Or is this limitation expected due to how Excel initializes the ribbon in new windows?
Any recommended patterns (event‑based activation, timing considerations, etc.) are welcome.
Thanks!
All reactions