Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming,microsoft.public.officedev
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
There are no "BeforeCalculate" or "AfterCalculate" events | Excel Discussion (Misc queries) | |||
Suppress popup "Do you really want to save..." after open and immediate close of excel sheets ? | Excel Worksheet Functions | |||
"Control" plus "click" doesn't allow me to select multiple cells | New Users to Excel | |||
Scroll Bar missing "Control" tab in "Format Properties" dialog box | Excel Discussion (Misc queries) | |||
"cannot insert object" in Excel (even a button from Control Toolbox) | Excel Programming |