Custom Menus delete

R

Rudy

Hi All. I've build my custom menu in a word template .dot using VBA
Code like this:
Set myMenuBar = CommandBars.ActiveMenuBar
Set newMenu = myMenuBar.Controls.Add(Type:=msoControlPopup,
Temporary:=True)
newMenu.Caption = "Ciao"
...

every time i close the template, i run the AutoExit Macro that delete
all custom bar like this:
Dim mnu As CommandBar
On Error Resume Next
For Each mnu In Application.CommandBars
mnu.Reset
Next mnu
i put the same code that reset all when i open the .dot document
placed in Word's startup folder

Why if i leave my template .dot from startup and i open a normal word
document the menu remains?

I think i have understading problems with AutoExec and other automatic
Macros...

Can you help me?
 
C

Cindy M -WordMVP-

Hi Rudy,

From what I can see, you're not setting the
Application.CustomizationContext. Word can save toolbars in four
different containers: NormalTemplate, a global template,
AttachedTemplate, or ActiveDocument. Your template in the Startup folder
would be a global template, part of the Templates collection. From your
description, the menus are being created instead in NormalTemplate, but
begin deleted from somewhere else (probably ActiveDocument).
I've build my custom menu in a word template .dot using VBA
Code like this:
Set myMenuBar = CommandBars.ActiveMenuBar
Set newMenu = myMenuBar.Controls.Add(Type:=msoControlPopup,
Temporary:=True)
newMenu.Caption = "Ciao"
...

every time i close the template, i run the AutoExit Macro that delete
all custom bar like this:
Dim mnu As CommandBar
On Error Resume Next
For Each mnu In Application.CommandBars
mnu.Reset
Next mnu
i put the same code that reset all when i open the .dot document
placed in Word's startup folder

Why if i leave my template .dot from startup and i open a normal word
document the menu remains?

I think i have understading problems with AutoExec and other automatic
Macros...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
V

vlad

Look what I've found:

WD2000 AutoExit Macro Does Not Remove Menu Items Added by AutoExec Macro
(Q245765)
(http://support.microsoft.com/?kbid=245765)

Try to create controls with CustomizationContext=ActiveDocument
and remove them with CustomizationContext=NormalTemplate.
This helped in my case. And make sure you've cleared your controls before
closing the .dot file!

Also, see my posting below.

good luck,
vlad.
 

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