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
 
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
 
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


>
 
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?
 
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?


>
 
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
chummy Open multiple Hyperlinks to download files Outlook VBA and Custom Forms 3
R Select Multiple Graphic Objects Using Outlook 0
Hornblower409 Automatically or Manually Backup Multiple Versions of VbaProject.OTM Outlook VBA and Custom Forms 1
B Modify VBA to create a RULE to block multiple messages Outlook VBA and Custom Forms 0
C Outlook 365 Multiple different Signatures on Shared Mailbox Using Outlook 0
R Advise on using multiple instances of network files based on customers Outlook VBA and Custom Forms 8
D multiple email accounts - why do I have to choose the "from" account address?? Using Outlook 2
J Outlook Rules VBA Run a Script - Multiple Rules Outlook VBA and Custom Forms 0
C How to search for items in Outbox with multiple accounts? Using Outlook 20
K How to share multiple calendar items Using Outlook 1
K Multiple copies of task being created Using Outlook 2
S Auto forward for multiple emails Outlook VBA and Custom Forms 0
K Multiple Rules on Single Email Using Outlook 2
Cathy Rhone gmail listed multiple times Using Outlook 3
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 8
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
M 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

Similar threads

Back
Top