views:

442

answers:

2

I am having some trouble with macros in my excel workbook. I have a couple of auto-shapes on one of my sheets which are grouped together for drawings. 2 of these have macros assigned to them (as 'kitchen - 1.xls'!but59 and 'kitchen - 1.xls'!but60), but I can't seem to assign macros to the other 2 shapes. I have tried right clicking on the shape, Assign Macro, select the macro that I wan to assign to, and then click Okay. But when I double check which macro it calls, it still calls *Baseunits_fbase3_3_Click* - it creates this new macro and I can't seem to force it to use my already written macro. Is there any other way to assign the macro that I need?


EDIT: I am kind of hoping that there is perhaps a way to assign the macro via VBA, but I can't see any reference to that in the online VBA reference anywhere. Does anyone know if this is possible?

A: 

I take it this is for Excel 2003??

What you are doing sounds correct. It sounds like there is a problem with the Grouping.

You have two options:

  1. In *Baseunits_fbase3_3_Click*, call the 'kitchen - 1.xls'!but59

  2. Delete all the objects in that group, and try again

The first option is a bit excessive and the second is a little drastic.

Good luck!

Christian Payne
Actually, Excel 2000 (XP). The second is not an option, because the group is a drawing I have made by piecing together various shapes. The first might be possible, but I can't really trust it either, because when I attempt to assign the correct macro, it actually creates a new macro each time (e.g. Baseunits_fbase3_1_Click, Baseunits_fbase3_2_Click, etc.) so I can't even rely on that to be constant.
a_m0d
I tried ungrouping everything and then regrouping (which should have a similar effect) but that didn't help at all!
a_m0d
I have now tried creating a totally new group, made up by copying each element of the original group individually, then grouping these, then grouping it all, and I still get the same problem
a_m0d
A: 

Okay, my solution to this (a bit of a hack, but it works) was to simply create a rectangle shape, give it no fill and no line, order it to the front, place it over the shape that the user has to click, and then assign the macro to this front shape.

Still no idea why I can't assign the macro to the original shapes, though - there has been quite a few like that now.

EDIT: I worked out how to assign the macro - I had to select the group, and then also select each of the shapes in the group, and assign the macro to all these selected shapes. This seemed to work consistently, and was also necessary in a number of cases for porting to Excel 2007.

a_m0d