creating menus

A

AB

Hi all?
I've done my macro that it's open when document is open (document_Open())
this macro creates my custom menu (right near the Word Info Menu)
i set this menu as temporary but everytime I open my .dot document (wheer i
write the code) i see another menu.

how can i add my menu once when i open the .dot and delete the old custom
voices?
 
C

Charles Maxson

A good rule of thumb in Office CommandBars is always (try to) delete the
menu you are about to create first just in case it already exists... here's
an example:

Dim cmb As CommandBar
Dim cmbc As CommandBarControl

On Error Resume Next
Set cmb = CommandBars("Document Properties")
If Not cmb Is Nothing Then
cmb.Delete
End If

Set cmb = CommandBars.Add("Document Properties", , , True)
With cmb
.Visible = True
.RowIndex = msoBarRowLast
.Position = msoBarTop
End With
 
C

Cindy M -WordMVP-

Hi Ab,
I've done my macro that it's open when document is open (document_Open())
this macro creates my custom menu (right near the Word Info Menu)
i set this menu as temporary but everytime I open my .dot document (wheer i
write the code) i see another menu.
1. The "Temporary" argument only works for COMMAND BARS, and not for buttons
on menus.

2. If this menu is specific for a document, or for all documents created from
a particular template, then it would make more sense to create the menu
directly IN that file. You wouldn't need any code at all. Just select the
container file in which you want to save it from the drop-down list in
Tools/Customize/Commands.

3. If you decide to go the route Charles suggests, and actively create/delete
the menu, then you MUST explicitly specify the CustomizationContext in Word
before creating/deleting. If you don't, you're going to have a royal mess on
the installation...

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 :)
 

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