sidharth

Hi all,

I have a word template solution in which i have several templates . i have customised the menu in word for these templates (hide Save, Save As and displayed a new option Save Me). but now i have a problem with all the word documents on my system. whenever i open a non-project word document this custom menu is getting loaded. i don't get the default menu available in WORD.

why is this happening. is it becoz the normal.dot got changed

why is this normal.dot affected by this project. what can i do to avoid that.



Re: Visual Studio Tools for Office Problem with Normal.dot???????

Cindy Meister

I'm assuming we're discussing Word 2003...

The Word application design has multiple places where changes to CommandBars can be saved. In the object model this is covered by the CustomizationContext property of the Application object. Customizations can be saved in: the current document, the current document's AttachedTemplate, any globally loaded template Add-in (see Tools/Templates and Add-ins, the list at the bottom) or the NormalTemplate (Normal.dot).

If you do not specify, general Word automation will tend to save anything added to the NormalTemplate, while deletions are often made in the current document. For this reason it's imperative that the CustomizationContext be specified in a procedure before changes to the CommandBars are made.

With a VSTO solution, the CustomizationContext should be pre-set to the project. But if anything happens to change the application's CustomizationContext, then the changes could appear elsewhere (in NormalTemplate, for example). I suspect that this is what has happened in your case.

On the machine(s) where you're seeing this you can start Word, go to Tools/Customize/Toolbars, select the Menu bar, then click Reset to recover the installation default.

Then add a line specifying the CustomizationContext at the beginning of all procedures to make sure the changes are made where you intend; either this.InnerObject or this.InnerObject.AttachedTemplate. Note that it would also be possible for you to open the VSTO template directly in Word and create the customizations there. Then all you'd need to do is hook up the Click events in your application.






Re: Visual Studio Tools for Office Problem with Normal.dot???????

Budro1890

Cindy Meister wrote:

With a VSTO solution, the CustomizationContext should be pre-set to the project.

It isn't for a Word Document project. But thanks for the information. This isn't documented well. I have Eric Carter's VSTO book and it's hidden in the CommandBar Events section. There really should be an entire section on creating toolbars, creating menus, enabling/disabling existing controls, and replacing existing controls.





Re: Visual Studio Tools for Office Problem with Normal.dot???????

Cindy Meister

I'd agree with you whole-heartedly, although the point has become somewhat moot since the release of Office 2007. In that version, commandbars are only used for right-click menus, so a lot of the discussion would no longer be relevant.

One of the best books for more information on the subject would be the "Professional Excel Development" book (Addison-Wesley). It doesn't handle any of the pitfalls of CommandBars in Word, but the information on using the commandbars object model is quite thorough.