Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Can I use VBA to assign Macro to Shape within a Group of Shapes?

Hi,
I have a group of shapes pre-built in one workbook that I want to copy to
another, then assign all the individual shapes to execute various macros in
the finished workbook.

I figured out how to do this on individual shapes this way:
ActiveSheet.Shapes("boxAF153").OnAction = "AF_Custom"

The question is if the shapes are copied over as part of a group, and I want
them to remain in a group, how do I refer to an individual shape within a
group?

I've tried the following but all give me "error 438".
The name of the shape Group is "Group 51" and one of the indvidual shapes is
"boxAF153"

ActiveSheet.Shapes.GroupItems("Group 51").Item("boxAF153").OnAction =
"AF_Custom"
ActiveSheet.GroupShapes(1).Items(1).OnAction = "AF_Custom"

Thanks for any help,
MikeZz

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Can I use VBA to assign Macro to Shape within a Group of Shapes?

You have to ungroup the shapes, assign a macro to each individual
shape and then regroup the shapes...
'--
ActiveSheet.Shapes.GroupItems("Group 51").Ungroup
ActiveSheet.Shapes("boxAF153").OnAction = "AF_Custom"
'assign more macros here
ActiveSheet.Shapes.Range("boxAF153").ReGroup
'--
MS didn't make it easy to understand.
--
Jim Cone
Portland, Oregon USA




"MikeZz"

wrote in message
Hi,
I have a group of shapes pre-built in one workbook that I want to copy to
another, then assign all the individual shapes to execute various macros in
the finished workbook.

I figured out how to do this on individual shapes this way:
ActiveSheet.Shapes("boxAF153").OnAction = "AF_Custom"

The question is if the shapes are copied over as part of a group, and I want
them to remain in a group, how do I refer to an individual shape within a
group?

I've tried the following but all give me "error 438".
The name of the shape Group is "Group 51" and one of the indvidual shapes is
"boxAF153"

ActiveSheet.Shapes.GroupItems("Group 51").Item("boxAF153").OnAction =
"AF_Custom"
ActiveSheet.GroupShapes(1).Items(1).OnAction = "AF_Custom"

Thanks for any help,
MikeZz

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
Calculate quantity of shapes inside another shape jlclyde Excel Discussion (Misc queries) 8 July 9th 11 06:00 AM
assign excel 2003 macro with parms to shape Marvin Excel Programming 2 January 3rd 07 07:33 AM
VBA Help with changing shape color for selected shapes only Nimrod[_2_] Excel Programming 8 April 29th 05 01:38 PM
Get the name of a group given the reference to a shape within the group Andrew[_16_] Excel Programming 5 January 1st 04 01:08 AM
Assign code to shape Jacob Excel Programming 1 November 4th 03 02:53 PM


All times are GMT +1. The time now is 10:29 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"