Strange issue with disappearing menu in Word AddIn

B

Bhimasena

Hi!

I have encountered a very strange problem: when specific .dot template is
opened in Word, or a document that was created from this template, the all
the menu items of my add-in menu disappear. If without closing that document
I open another one (from normal.dot) the menu is alright. The problem appears
only if the template itself is opened or is accessible to the document (If
create a document form the template and then rename the template, the problem
won't reproduce).

I have a workaround for the problem: create a document from a problematic
template, and then save it as a new template. The new template do not cause
any problems.

The question is why this problem might happen at the first place and how can
I avoid it in add-in code?
 
P

Peter Huang [MSFT]

Hi IIya,

The problem is somewhat strange.
Commonly, if we add a toolbar or button in word, and save close the word.
The Added Toolbar information will be saved in the normal.dot.
So that may be cause that you did not see the toolbar when you are not
using normal.dot.

Also I think you may try to design the code as below.
When the Addin startcomplete, we can try to detect if the toolbar/button
already exist.(using FindControl)
If no, we can add them. If yes, just get the reference and attach event
handle.

Also I suggest you add the button/toolbar temporarily and delete them in
the BeginShutDown event.
So that the toolbar/button only exists when word and addin is alive, we did
not touch the normal.dot.


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Bhimasena

Hi Peter!
Thanks for a speedy reply!

As a matter of a fact, my add-in creates the menu almost the way you have
advised: it is created on Connection and deleted on Disconnection. Moreover
CustomizationContext is explicitly set to NormalTemplate and
NormalTemplate.Saved is always set to True after any changes in the menu, so
that no changes should be saved.

I think the problem might be in some menu settings that were saved in those
problematic templates that somehow collide with the add-in menu.

Is there a way to see the internals of a .dot template?
 
P

Peter Huang [MSFT]

Hi Ilya,

Based on my knowledge, so far there is no such a tool to "read" the dot
file directly.
But I think you may try to create another template other than the
normal.dot to see if the problem persists.

Also based on our addin logic, if it detected the toolbar is not there, it
should try to add a new one.
So I think you may try to trace the code in the
OnConnection/OnStartupComplete to see why the Toolbar is not added.
e.g.
Was the OnConnection called when the problem occurred?


Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top