Multiple Toolbars being added/Multiple Buttons being added to Mail

Status
Not open for further replies.
T

TWF0dA

Hello,

I am developing an outlook add-in which requires a single toolbar with a

single button being added to the MailEditor window. Upon debugging my project

the first time, the button is created and all is well. However, after closing

outlook and debugging again, a duplicate toolbar is added (with the button).

This continues to happen and toolbar after toolbar is added. I manually

remove the Add-In and restart Outlook and the buttons are still there, the

only way to remove them is by restarting my PC, and it just happens again.

How would I go about solving this problem?

Thanks
 
K

Ken Slovak - [MVP - Outlook]

Always make sure to set the UI you create as temporary, and then delete it

before the relevant Explorer or Inspector closes.

"Matt" <Matt> wrote in message

news:FA6B01D5-0F6E-42D6-A6AC-EFDE57046C1E@microsoft.com...
> Hello,

> I am developing an outlook add-in which requires a single toolbar with a
> single button being added to the MailEditor window. Upon debugging my
> project
> the first time, the button is created and all is well. However, after
> closing
> outlook and debugging again, a duplicate toolbar is added (with the
> button).
> This continues to happen and toolbar after toolbar is added. I manually
> remove the Add-In and restart Outlook and the buttons are still there, the
> only way to remove them is by restarting my PC, and it just happens again.
> How would I go about solving this problem?

> Thanks
 
T

TWF0dA

Re: Multiple Toolbars being added/Multiple Buttons being added to

I'm fairly new to Outlook programming, how do I do that?
wrote:


> Always make sure to set the UI you create as temporary, and then delete it
> before the relevant Explorer or Inspector closes.

> >

>

> "Matt" <Matt> wrote in message
> news:FA6B01D5-0F6E-42D6-A6AC-EFDE57046C1E@microsoft.com...
> > Hello,
> > I am developing an outlook add-in which requires a single toolbar with a
> > single button being added to the MailEditor window. Upon debugging my
> > project
> > the first time, the button is created and all is well. However, after
> > closing
> > outlook and debugging again, a duplicate toolbar is added (with the
> > button).
> > This continues to happen and toolbar after toolbar is added. I manually
> > remove the Add-In and restart Outlook and the buttons are still there, the
> > only way to remove them is by restarting my PC, and it just happens again.
> > How would I go about solving this problem?
> > Thanks


>
 
K

Ken Slovak - [MVP - Outlook]

Re: Multiple Toolbars being added/Multiple Buttons being added to

The CommandBars.Add() method has a temporary argument, set it to True if you

create a new CommandBar object. The CommandBarControls.Add() method also has

that argument available when you add a new control to a CommandBar

(menu/toolbar). Also set that True.

That's generally enough, but if for some reason Outlook doesn't correctly

close or crashes a belt plus suspenders approach is to handle the

Inspector.Close() event on any Inspector you are adding UI to, and the

Explorer.Close() event on any Explorer you add UI to. In those event

handlers you get your references to the controls and commandbars you added

and call their Delete() method to delete them.

There's lots of sample code in various languages at www.outlookcode.com that

shows handling those Close() events and how to handle adding and removing

UI. Take a look there for samples in your language.

"Matt" <Matt> wrote in message

news:5197F2DC-3B71-4727-A6B9-778C8CEBD537@microsoft.com...
> I'm fairly new to Outlook programming, how do I do that?
 
T

TWF0dA

Re: Multiple Toolbars being added/Multiple Buttons being added to

My commandbar was set as temporary but the button was not. Is this way correct:

button_1 = CType(newToolBar.Controls.Add(1, 1, Nothing, Nothing, True),

Office.CommandBarButton)

?
wrote:


> The CommandBars.Add() method has a temporary argument, set it to True if you
> create a new CommandBar object. The CommandBarControls.Add() method also has
> that argument available when you add a new control to a CommandBar
> (menu/toolbar). Also set that True.

> That's generally enough, but if for some reason Outlook doesn't correctly
> close or crashes a belt plus suspenders approach is to handle the
> Inspector.Close() event on any Inspector you are adding UI to, and the
> Explorer.Close() event on any Explorer you add UI to. In those event
> handlers you get your references to the controls and commandbars you added
> and call their Delete() method to delete them.

> There's lots of sample code in various languages at www.outlookcode.com that
> shows handling those Close() events and how to handle adding and removing
> UI. Take a look there for samples in your language.

> >

>

> "Matt" <Matt> wrote in message
> news:5197F2DC-3B71-4727-A6B9-778C8CEBD537@microsoft.com...
> > I'm fairly new to Outlook programming, how do I do that?


>
 
K

Ken Slovak - [MVP - Outlook]

Re: Multiple Toolbars being added/Multiple Buttons being added to

For optional missing values use System.Reflection.Missing.Value instead of

using Nothing. I usually define a class or global _missing variable object

for that.

In general, unless you are using a built-in control it's usually better to

not specify the ID argument and to supply the missing value for that also.

So I'd code that as:

button_1 = CType(newToolBar.Controls.Add(1, _missing, _missing, _missing,

True),

Office.CommandBarButton)

Also, when you set the other properties of any button you create make sure

to always use a unique Tag property. That prevents the button Click() event

from firing as many times as you have open items (Inspectors) or open folder

views (Explorers). With a unique Tag the Click() will fire only in that one

Inspector or Explorer.

"Matt" <Matt> wrote in message

news:9341D507-A4D0-49DD-8FDB-B070B9A9B535@microsoft.com...
> My commandbar was set as temporary but the button was not. Is this way
> correct:

> button_1 = CType(newToolBar.Controls.Add(1, 1, Nothing, Nothing, True),
> Office.CommandBarButton)

> ?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
H Synchronize contacts and calendars across multiple devices Using Outlook 0
V Outlook 2016 Multiple recurring tasks getting created Using Outlook 0
K can't get custom form to update multiple contacts using VBA Outlook VBA and Custom Forms 3
Globalforester ItemAdd Macro - multiple emails Outlook VBA and Custom Forms 3
J Multiple calendars Using Outlook 0
C Multiple emails Using Outlook 3
C Outlook with Office365 - search across account, by date rate, in multiple folders - how? Using Outlook 2
E Asking user to select multiple options in a list in an email Outlook VBA and Custom Forms 0
A Multiple signatures Using Outlook 2
O Outlook tasks - Add text column with multiple lines Using Outlook 3
R How to get the Items object of the default mailbox of a specific account in a multiple account Outlook? Outlook VBA and Custom Forms 0
I Saving attachments from multiple emails and updating file name Outlook VBA and Custom Forms 0
L Multiple Inboxes Using Outlook 3
RBLampert Accessing Outlook accounts from multiple computers Using Outlook 8
Martull Forced signature when multiple accounts exist Outlook VBA and Custom Forms 4
T Outlook 2010 Correct way to map multiple contact fields Using Outlook 4
Y Open and Save Hyperlink Files in multiple emails Outlook VBA and Custom Forms 9
O Multiple email accounts - hesitate to create a new profile Using Outlook 3
papa.deblanc Multiple Instances Using Outlook 6
V Multiple Calendars in Outlook To-Do Bar; Office 365 Using Outlook 3
A Add multiple servers "on behalf of" email to "safe senders" list. Using Outlook 1
M possible to search Outlook for multiple email addresses at once? Using Outlook 1
C Macro to add multiple recipients to message Outlook VBA and Custom Forms 3
D [TOOL] QuickModules to sort emails very quickly to multiple folders Outlook VBA and Custom Forms 1
A Multiple Outlook Invites Received by One Person Using Outlook 4
N Selecting multiple calendar items Using Outlook 4
F Sharepoint tasks from multiple accounts in To-Do List Using Outlook 8
N Multiple instances of Outlook on Start Menu Using Outlook 2
D Edit Subject (Multiple Accounts) Outlook VBA and Custom Forms 5
B VBA Macro for assigning multiple Categories to an email in my Inbox Outlook VBA and Custom Forms 1
L Need to import multiple Outlook files to Office 365 Account Using Outlook 4
B Deleting multiple accounts Using Outlook 1
I Dialog called up multiple times when saving emails from macro Outlook VBA and Custom Forms 2
M Multiple spurious empty folders appear in archive files Using Outlook 3
G Bcc help - Preventing multiple forwards from a bcc'd distribution group Using Outlook 1
J Outlook Rules - Changing auto-submit address in multiple rules, according to rule name Outlook VBA and Custom Forms 0
F Send multiple batch tasks to single person Using Outlook 3
M Multiple workstations and multiple accounts - keep in sync? Using Outlook.com accounts in Outlook 2
A Sending Emails Through Outlook From Multiple Email Addresses Using Outlook 1
S How to extract mail items from multiple folders and shared mailboxes? Outlook VBA and Custom Forms 0
A open Outlook with multiple windows. Using Outlook 0
M Ensure the same inbox view across multiple outlook instances Using Outlook.com accounts in Outlook 7
D Multiple mailboxes, 1 certificate. How to prevent message "Invalid Certificate" Using Outlook 0
R Using Multiple Accounts in Outlook Using Outlook 3
D Multiple Accounts Issue Receiving Emails in 2016 Using Outlook 0
M Multiple User Defined Fields that can be added, changed, updated using VBA and user form Outlook VBA and Custom Forms 0
Diane Poremsky Combine and Print Multiple Outlook Calendars New Slipstick.com Articles 0
Jeanne Goodman Create Printout from Multiple Shared Calendars Outlook VBA and Custom Forms 8
Y Creating custom appointment request form with multiple mail recipients Outlook VBA and Custom Forms 5
B Macro To Create Rule To Export From Certain Folder Email Information in one workbook multiple sheets Outlook VBA and Custom Forms 0

Similar threads

Top