Temporary Property on Office CommandBar and CommandBarButton Obj's

S

StevenBr

In my Outlook add-in, I'm creating a commandbar with one button, as follows:

Set cbrTessOLBar = Inspector.CommandBars.Add("cbTessOL", msoBarTop, False,
True)
Set cbTessOLLogSend = cbrTessOLBar.Controls.Add(msoControlButton, , , ,
True)

The last argument, according to the docs, is Temporary, indicating that the
commandbar and button should be destroyed when the inspector is.

That doesn't occur; as I continually open inspectors, new commandbars are
added each time. Does "Temporary" really work, or do I have to destroy the
commandbar in code?

Thanks.
 
P

Peter Huang [MSFT]

Hi Steven,

Based on my experience, commonly we will Delete the Button and set it to
nothing before addin is shut down.

Also from the document below.
Temporary Optional Variant. True to make the new control temporary.
Temporary controls are automatically deleted when the container application
is closed. The default value is False.

It seems that the controls is deleted when the conatiner application is
closed. You may try to close outlook.exe(NOTE: the process needed closed)
and restart to see if the commandbar is still there.

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Ken Slovak - [MVP - Outlook]

It's always a best practice to destroy the object even if it's declared as
temporary. When Outlook closes is when temporary things are destroyed.

Where are you creating your buttons, in what event handler?

I use Inspector wrapper classes, instantiated in the NewInspector event. I
then add my buttons in the first Inspector.Activate event. When the
Inspector or Inspector.CurrentItem is closed I delete and release my button
objects.

One thing to bear in mind is if WordMail is being used. In that case all
bets on temporary are off. WordMail does not honor temporary, and you get no
error. It accepts that argument and ignores it. In cases of WordMail you
must explicitly delete your buttons as well as play with the
Word.CustomizationContext to ensure the user doesn't get a prompt to save
the normal template after adding/deleting the buttons.
 

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