Autoshapes and macros/actions PPT 2010

laceless
NewLounger
Posts: 2
Joined: 17 Jan 2012, 11:28

Autoshapes and macros/actions PPT 2010

Post by laceless »

Hello,

I am using Powerpoint 2010 (64 bit) under Windows 7 Home Premium (64 bit) and am trying to associate macros with autoshapes. Unfortunately I can find no way of doing this.

The sequence:

New Slide | Insert Autoshape | Right Click Autoshape

produces a pop-up menu with several choices but it does not include a choice for associating either a macro or action with the autoshape.

I must be doing something wrong but I cannot see what. Or is it that PPT 2010 (64 - bit) does not have the required feature?

Any and all help appreciated

Many thanks

Laceless

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Autoshapes and macros/actions PPT 2010

Post by HansV »

Welcome to Eileen's Lounge!

Select the shape, then click Action on the Insert tab of the ribbon.
Click Macro, then select a macro from the dropdown. (The Macro option will only be enabled if there are macros).
Finally, click OK.
S00009.png
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

laceless
NewLounger
Posts: 2
Joined: 17 Jan 2012, 11:28

Re: Autoshapes and macros/actions PPT 2010

Post by laceless »

Many thanks.

had not appreciated that the 'Run macro' option would only be available if there was at least one available macro. So obvious really

Laceless

Asher
2StarLounger
Posts: 169
Joined: 08 Jun 2010, 14:33
Location: Massachusetts, USA

Re: Autoshapes and macros/actions PPT 2010

Post by Asher »

Hi,

I'm new to coding in PPT. I have a project someone has requested and to get started I have been browsing this forum. I think this is the right post to ask my questions in since there are many autoshapes in the PPT that I am being asked to code.

Q1. I see above that there is a way to access a macro from an autposhape via the insert menu. I am assuming I would just add a module and write the code and assign it to the correct autoshape. However, if I am writing code that makes one autoshape do something to another autoshape, how do I know what that autoshape is called? I don't see a properties area for each autoshape that tells me its name, like when I add a command button I can go into properties and see that it is command button 1 and even view the code. But with the autoshapes I see no properties telling me how to call it in code.

-Asher

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Autoshapes and macros/actions PPT 2010

Post by HansV »

You can see the name of a shape as follows:
- Select the shape.
- Activate the Visual Basic Editor (Alt+F11).
- Activate the Immediate window (Ctrl+G).
- Type the following line (or copy/paste it), then press Enter:

Code: Select all

? ActiveWindow.Selection.ShapeRange.Name
You can also change the name of the selected shape if you would prefer a more meaningful one:

Code: Select all

ActiveWindow.Selection.ShapeRange.Name = "MyShape"
Once you know (or set) the name, you can use it to refer to the shape without having to select it, for example:

Code: Select all

ActiveWindow.View.Slide.Shapes("Myshape").Fill.ForeColor.RGB = vbRed
Warning: PowerPoint VBA is weird and the help file is a joke.
Best wishes,
Hans

Asher
2StarLounger
Posts: 169
Joined: 08 Jun 2010, 14:33
Location: Massachusetts, USA

Re: Autoshapes and macros/actions PPT 2010

Post by Asher »

Thanks for your answer Hans, I have indeed noticed that about the help file. I'll play around with what you gave me though, and hopefully i can get somewhere with it. :smile: