Addin Toolbar Button Click Event Fires Twice in PPT with 2 Presentations Open

G

Gary McGill

Hi,

I have a shared COM add-in for Office 2003 (Word, Excel, PowerPoint) that I
developed using Visual Studio 2003 (C#).

The add-in has a toolbar, which is the same in all 3 applications.
Everything works fine, except in one strange circumstance: if I have 2
PowerPoint presentations open at once, then every time I click on a button
on my toolbar, the button click event fires twice. (I can tell this because
the dialog comes up, I click OK, and then the dialog comes up again). This
only happens with PowerPoint, and not with Word or Excel.

Here's a snippet of the code I have in my OnStartupComplete method:

Office.CommandBars commandBars = (Office.CommandBars)
this._application.GetType().InvokeMember("CommandBars",
BindingFlags.GetProperty, null, this._application, null);

// Add the data command bar

this._dataCommandBar = commandBars.Add(DataCommandBarName, Type.Missing,
Type.Missing, true);

this._dataCommandBar.Position = Office.MsoBarPosition.msoBarTop;

// About button

this._aboutButton = (Office.CommandBarButton)
this._dataCommandBar.Controls.Add(Office.MsoControlType.msoControlButton,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);

this._aboutButton.Tag = "aboutButton";
this._aboutButton.Priority = 1;
this._aboutButton.Style = Office.MsoButtonStyle.msoButtonIcon;
this._aboutButton.FaceId = 487;
this._aboutButton.Caption = "About";
this._aboutButton.TooltipText = "Display program version and copyright
information.";
this._aboutButton.OnAction = "!<FleetAddin.Connect>";
this._aboutButton.Visible = true;

this._aboutButtonClickEventHandler = new
Office._CommandBarButtonEvents_ClickEventHandler(this.AboutButton_Click);

this._aboutButton.Click += this._aboutButtonClickEventHandler;

Has anyone else seen this behaviour? Is there something special I need to do
with PowerPoint to avoid it?

Thanks,
Gary
 

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