Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Adding a Menu

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Albert - 18 Aug 2006 23:10 GMT
Hello!
I'd like to add a new menu after the tools and before the help menu. I would
like to do it through VBA so that when the user opens the document, the menu
appears, and when the workbook is closed, the menu disappears.
How should I go about it?
THanks,
Albert
Jezebel - 19 Aug 2006 00:35 GMT
Is there a particular reason you want to use VBA for this? Since the code
has to be stored somewhere -- either the document itself, or (better) the
template on which the template is based -- why not just manually add the
menu to the document or template? Then it will be shown only when the
document or template is in use, and go away of its own accord when the
document or template closes.

If you do want to do it with VBA, set the CustomizationContext (the VBA
equivalent of the 'Save In' drop-down on the Customize dialog), then use the
methods of the CommandBars collection. Note that this collection is part of
Office, not part of Word. Also make sure you have backups of your document
*and all your templates* -- there is a glitch in some versions of Word
(can't remember which ones) relating to the CustomizationContext, which
results in terminal corruption of the active template.

> Hello!
> I'd like to add a new menu after the tools and before the help menu. I
[quoted text clipped - 5 lines]
> THanks,
> Albert
Albert - 19 Aug 2006 02:58 GMT
Hi Jezebel.
The thing is I'm making a special and highly personalized mailmerge document
for someone, and I want to have all the macros executed from a personalized
menu. Also, I want the menu to appear when they open the document, and to
disappear when they close.
That's why I want it done through vba.
Albert
Shauna Kelly - 19 Aug 2006 03:37 GMT
Hi Albert

May I suggest that you do the following. Perhaps even do a little dummy test
as a 'proof of concept' exercise:

1. Do File > Save As and in the "Save as type" box, choose to save as a
Template. Save it at the location identified at Tools > Options > File
Locations > User Templates.

2. Use Tools > Customize to create a new toolbar and make sure (from the
Commands tab on the Tools > Customize dialog) that you are saving the
toolbar in your template.

3. Use Tools > Customize to add buttons and menus as you need. Again, make
sure you're saving them in your template. While the Tools > Customize dialog
is open, you can right-click any button to change the text and icon.

4. Save and close.

5. Open one or two other documents, just to demonstrate.

5. Do File > New. Choose your template. You will now see that, when you swap
from one document to the other, your toolbar will appear only in the
document based on your template, and it will disappear when you view
documents based on other templates.

In Excel, you need to do all this in code. Word does it for you.

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

> Hi Jezebel.
> The thing is I'm making a special and highly personalized mailmerge
[quoted text clipped - 5 lines]
> That's why I want it done through vba.
> Albert
Jezebel - 19 Aug 2006 03:57 GMT
That doesn't explain it at all. You still have to put all those macros
somewhere: put the menu in the same document or template that contains the
code.

> Hi Jezebel.
> The thing is I'm making a special and highly personalized mailmerge
[quoted text clipped - 5 lines]
> That's why I want it done through vba.
> Albert
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.