Application.CommandBars("MyBar").Delete

P

Pierre Duc

I use :

Application.CommandBars("MyBar").Delete

to delete a command bar.

This instruction works fine, but the next time I launch Word, the command
bar re-appears !

Why ? and how to resolve ?

Pierre.
 
P

Perry

De-Attach the commandbar's context from (I presume) normal.dot by including
following statements:
To investigate whether normal.dot hosts the commandbar, rename normal.dot to
normal.org and startup Word, if the commandbar isn't there, it's hosted by
normal.dot and use below lines to restore the "normal" situation.

CustomizationContext = NormalTemplate
Application.CommandBars("MyBar").Delete
NormalTemplate.Save

If that doesn't fix it, try this line somewhere in the code
MsgBox(Application.CommandBars("MyBar").Context)
or
Debug.Print Application.CommandBars("MyBar").Context)
Locate the template and de-attach the commandbar using similar lines as
above, but point the
CustomizationContext clause to the target template, like in below lines

Dim tmp As Template
Dim d As Document
Set d = Documents.Add("c:\templates\MyTemplate.dot")
Set tmp = d.AttachedTemplate
CustomizationContext = tmp

Application.CommandBars("MyBar").Delete
tmp.Save

Next time you go about building up the/a commandbar, be aware of the
template context yr addressing.
More info on CustomizationContext clause, see below URL (from http through
to .asp)

http://msdn.microsoft.com/library/d...tml/woproCustomizationContext1_HV05210405.asp


-------------------------------------
Krgrds,
Perry

System parameters:
POS: WinXP SP2
MSO: MSOffice 2003 SP2
DEV: VS8 (dotnet)
 

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