View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default passing commandbars to a procedure

Doug,

Your preferred way will work, but cBar is a CommandbarControl in this case,
not type Commandbar.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Doug Glancy" wrote in message
...
I have a procedure that takes a commandbar object as it's argurment:

Sub modify_insert_delete_buttons(cbar As CommandBar, Optional delete As
Boolean = False)

It modifies Excel's existing Insert Rows and Delete Rows buttons on

various
Excel commandbars including the Edit menu and the Cells right-click menu.
In the procedure I need to use FindControl which seems to be only

available
with CommandbarPopups, not Commandbars. In order to pass the Edit menu to
my routine I've done this in the calling procedu

Dim cbar As CommandBar
Set cbar = Application.CommandBars("Worksheet Menu
Bar").FindControl(ID:=30003).Controls(1).Parent 'Edit menu

Is there a better way to do this, without calling the Parent of a Control

on
the Edit menu? It seems like the following should work, but it gives a

type
mismatch error:

Set cbar = Application.CommandBars("Worksheet Menu
Bar").FindControl(ID:=30003)

Again, the way I'm doing it works, I just wonder if there's a better way.

thanks,

Doug