Office 2000 Add-in CommandBarButton event problem ( C# )

J

John Hamilton

Applies to Excel, Word, and PPT

Simple scenario: When no document is open, I disable my CommandBarButtons in
my CommandBarPopup's Controls collection.

foreach( CommandBarButton btn in mMenu.Controls ){ btn.Enabled = false; }

When I create a new document or open an existing document, I want to renable
my CommandBarButtons. I do so by getting the reference to each button and
setting Enabled = true;

btnLinkPic = (CommandBarButton)mMenu.Controls[ LINK_PICTURE_BUTTON ];
btnLinkPic.Enabled = true;

The Click event for each button is wired upon the add-in connect, and never
twice.

The problem: After closing a document, and opening/creating a document, the
Click event of the button fires twice.

Any suggestions?

Best regards,

John Hamilton
net Fusion Corp.
 
K

Keith Tromer

John,

Make sure that all commandbuttons have unique .Tag properties. It doesn't
make sense to me either, but that can cause this problem

Keith Tromer
PowerTools - Productivity add-ins for PowerPoint
www.corpimaging.com/PowerTools
 
J

John Hamilton

Good gravy!

That did the trick... what a peculiar behavior. What's up, MS? I swear, if I
ever have to write another add-in in .NET, I'm gonna scream. :)

Thanks soooooo much Keith.

Best regards,

John Hamilton

Keith Tromer said:
John,

Make sure that all commandbuttons have unique .Tag properties. It doesn't
make sense to me either, but that can cause this problem

Keith Tromer
PowerTools - Productivity add-ins for PowerPoint
www.corpimaging.com/PowerTools


John Hamilton said:
Applies to Excel, Word, and PPT

Simple scenario: When no document is open, I disable my CommandBarButtons in
my CommandBarPopup's Controls collection.

foreach( CommandBarButton btn in mMenu.Controls ){ btn.Enabled = false; }

When I create a new document or open an existing document, I want to renable
my CommandBarButtons. I do so by getting the reference to each button and
setting Enabled = true;

btnLinkPic = (CommandBarButton)mMenu.Controls[ LINK_PICTURE_BUTTON ];
btnLinkPic.Enabled = true;

The Click event for each button is wired upon the add-in connect, and never
twice.

The problem: After closing a document, and opening/creating a document, the
Click event of the button fires twice.

Any suggestions?

Best regards,

John Hamilton
net Fusion Corp.
 
K

Keith Tromer

No Problem John.

Keith Tromer
PowerTools - Productivity add-ins for PowerPoint
www.corpimaging.com/PowerTools


John Hamilton said:
Good gravy!

That did the trick... what a peculiar behavior. What's up, MS? I swear, if I
ever have to write another add-in in .NET, I'm gonna scream. :)

Thanks soooooo much Keith.

Best regards,

John Hamilton

Keith Tromer said:
John,

Make sure that all commandbuttons have unique .Tag properties. It doesn't
make sense to me either, but that can cause this problem

Keith Tromer
PowerTools - Productivity add-ins for PowerPoint
www.corpimaging.com/PowerTools


John Hamilton said:
Applies to Excel, Word, and PPT

Simple scenario: When no document is open, I disable my
CommandBarButtons
in
my CommandBarPopup's Controls collection.

foreach( CommandBarButton btn in mMenu.Controls ){ btn.Enabled = false; }

When I create a new document or open an existing document, I want to renable
my CommandBarButtons. I do so by getting the reference to each button and
setting Enabled = true;

btnLinkPic = (CommandBarButton)mMenu.Controls[ LINK_PICTURE_BUTTON ];
btnLinkPic.Enabled = true;

The Click event for each button is wired upon the add-in connect, and never
twice.

The problem: After closing a document, and opening/creating a document, the
Click event of the button fires twice.

Any suggestions?

Best regards,

John Hamilton
net Fusion Corp.
 

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