Creating a temporary CommandBarControl

L

Luc

Hello,

I'm just confused by this 'temporary' thing.

I would like to add a CommandBarControl to the Menu Bar in Word, but it should be 'deleted' when Word closes. So I use "temporary=True". However when I close Word and restart it. That commandBarControl is still there?

Why is my CommandBarControl still available after Word is restarted (using temporary=true)?

' Code starts here
Sub Add()

Dim MyControl As CommandBarControl
Dim strMacroName As String

Set MyControl = CommandBars.ActiveMenuBar.Controls.Add(msoControlPopup, _
Before:=2, _
Temporary:=True)
MyControl.Caption = "MyCaption"

End Sub
' Code ends here

I know how to delete the CommandBarControl but what's the purpose of "temporary" if it is persistant?
 
C

Charles Maxson

Luc,

So I am NOT crazy! I have seen this randomly occur time and time again too -
I declare my commandbars temporary and STILL delete them when I leave the
document/application just because I have seen this. Anyone else out there
been able to make Temporary work permanently correct?

--
Charles
www.officezealot.com


Luc said:
Hello,

I'm just confused by this 'temporary' thing.

I would like to add a CommandBarControl to the Menu Bar in Word, but it
should be 'deleted' when Word closes. So I use "temporary=True". However
when I close Word and restart it. That commandBarControl is still there?
Why is my CommandBarControl still available after Word is restarted (using temporary=true)?

' Code starts here
Sub Add()

Dim MyControl As CommandBarControl
Dim strMacroName As String

Set MyControl = CommandBars.ActiveMenuBar.Controls.Add(msoControlPopup, _
Before:=2, _
Temporary:=True)
MyControl.Caption = "MyCaption"

End Sub
' Code ends here

I know how to delete the CommandBarControl but what's the purpose of
"temporary" if it is persistant?
 
T

Thomas Winter

Luc said:
Hello,

I'm just confused by this 'temporary' thing.

I would like to add a CommandBarControl to the Menu Bar in Word, but it
should be 'deleted' when Word closes. So I use "temporary=True". However
when I close Word and restart it. That commandBarControl is still there?
Why is my CommandBarControl still available after Word is restarted (using temporary=true)?

' Code starts here
Sub Add()

Dim MyControl As CommandBarControl
Dim strMacroName As String

Set MyControl = CommandBars.ActiveMenuBar.Controls.Add(msoControlPopup, _
Before:=2, _
Temporary:=True)
MyControl.Caption = "MyCaption"

End Sub
' Code ends here

I know how to delete the CommandBarControl but what's the purpose of
"temporary" if it is persistant?

One thing to remember is that the CommandBar object model is part of Office
in general, not just Word. SOME of the Office applications implement the
Temporary property, some do not. Word does NOT use the Temporary property.
Sorry.

If you need to delete your commandbar, maybe put the code in an AutoExit
macro. You could also put the commandbar permenantly in a .DOT add-in that
your code loads and unloads (through Application.AddIns). You can do this in
a COM Add-In or another .DOT add-in. If you want more explanation, let me
know!

-Tom
 

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