Installing and removing toolbars

  • Thread starter christophercbrewster via OfficeKB.com
  • Start date
C

christophercbrewster via OfficeKB.com

I'm creating a set of macros for a group of people to use. I'm new to giving
these to other users. I've created a toolbar, and I want a user to be able to
install it so that it's visible by default and listed on View > Toolbars.
While experimenting with this, I realized the list of toolbars showed the new
toolbar name ~25 times, once for each time I ran CommandBars.Add. This was my
mistake, but I don't see how to remove these from the list. [Note: the code
even checks to see if it is already present, but this check must not work.]

Am I right in thinking that the toolbar would be installed as a one-time
operation, or should it be re-established each time the program opens? Is
AutoOpen the right way to do this?

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200811/1
 
C

Cindy M.

Hi Christophercbrewster,
I'm creating a set of macros for a group of people to use. I'm new to giving
these to other users. I've created a toolbar, and I want a user to be able to
install it so that it's visible by default and listed on View > Toolbars.
While experimenting with this, I realized the list of toolbars showed the new
toolbar name ~25 times, once for each time I ran CommandBars.Add. This was my
mistake, but I don't see how to remove these from the list. [Note: the code
even checks to see if it is already present, but this check must not work.]

Am I right in thinking that the toolbar would be installed as a one-time
operation, or should it be re-established each time the program opens? Is
AutoOpen the right way to do this?
Can you give us more information about the "container" you're distributing to
the users? Is this a Word document? A template? Something else?

One thing you have to be careful about when manipulating CommandBar objects in
Word is the CustomizationContext. This determines where (which file, doc or
dot) the changes are saved. If you don't specify it, Word makes a "best guess",
which can end up in things being created in one "container", changed in
another, and deleted from yet another.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :)
 
C

christophercbrewster via OfficeKB.com

Cindy-- I got an answer elsewhere, which worked. But you raise issues that I
need to understand better. I'm distributing the macros as an Add-in. Assuming
there will be later versions, the multiple-toolbar-entry problem would recur.
So my Auto_Open now contains this code:

Dim myToolbar As String
myToolbar = "Editing Functions"

Dim oCmd As CommandBar ' Kill the toolbar that is already
installed and re-install
For Each oCmd In ActiveDocument.CommandBars
If oCmd.Name = myToolbar Then
oCmd.Delete
End If
Next

Please let me know if you see potential problems using this. Thanks.

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200811/1
 
D

Doug Robbins - Word MVP

If the later versions are replacements for the previously installed add-in,
(i.e. there would only be one version of the add-in loaded) then the problem
should not occur

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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