Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.officedev
external usenet poster
 
Posts: 1
Default How do I get events from a "Split Button Popup" control?

I want to execute some VBA addin (or possibly C# COM addin) code any
time that a user pastes data into an office document. To accomplish
this, I've added event handlers to the cut, copy and paste commands in
Excel. This is done by finding the commands (21, 19 and 22) in the
CommandBars collection by command ID and setting up "_Click" handlers
for each command. The default "Standard" toolbar contains a paste
control (ID 6002) that is a CommandBarPopup instead of a
CommandBarButton. Unfortunately, this popup type does not source any
events. I can successfully sink events from the items on the popup
menu from this popup button, but not from the button itself. How can
I get notification that this button has been clicked?

Any information would be greatly appreciated, I've tried everything I
can think of on this one. Please CC any responses to me via e-mail at
.

Thanks!

===== Begin VBA Addin (.xla) Source =====

' This allows us to get events from the "standard" paste commands
Private WithEvents PasteButton As Office.CommandBarButton

' Attempting declare a CommandBarPopup with events fails:
' "Object does not source automation events"
'Private WithEvents PastePopup As Office.CommandBarPopup


Private Sub Workbook_Open()
' Find the "standard" paste button to begin sinking events
Set PasteButton =
Application.CommandBars.FindControl(Type:=msoContr olButton, ID:=22)

' Find the "split button popup" type paste command
Dim PastePopup As CommandBarPopup
Set PastePopup =
Application.CommandBars.FindControl(Type:=msoContr olSplitButtonPopup,
ID:=6002)

if (Not PastePopup Is Nothing) then
' Events can be trapped from buttons on the popup's
' embedded command bar...
'Set Paste1 = PastePopup.Controls.Item(1)

' Attempting to set an OnAction handler for this control
' results in an error:
' "Object doesn't support this property or method"
'PastePopup.OnAction = "ThisWorkbook.TaskTracerPaste"

' Attempting to assign the "split button popup" control
' to a CommandBarButton object that can source events
' results in an invalid cast error.
end if
End Sub

===== End VBA Addin (.xla) Source =====
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
There are no "BeforeCalculate" or "AfterCalculate" events Conan Kelly Excel Discussion (Misc queries) 2 December 7th 07 10:30 PM
Suppress popup "Do you really want to save..." after open and immediate close of excel sheets ? Markus Obermayer Excel Worksheet Functions 2 January 2nd 07 02:12 PM
"Control" plus "click" doesn't allow me to select multiple cells Ken Cooke New Users to Excel 0 September 25th 06 04:46 PM
Scroll Bar missing "Control" tab in "Format Properties" dialog box Peter Rooney Excel Discussion (Misc queries) 5 August 24th 06 05:36 PM
"cannot insert object" in Excel (even a button from Control Toolbox) Matthew Lee Excel Programming 1 April 30th 04 05:58 PM


All times are GMT +1. The time now is 11:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"