Change background color of shape through macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was asked to figure out a way to change the background color of some shapes
in a slide show by just clicking on them.

I've got a macro to do that. I've right-clicked on the object and chose
"Action Settings" Under On Click, I picked the name of the macro to run.
Nothing happens.

Now, I am not an expert or even a casual user of Power Point. I don't
really know what I am doing. I do know Excel and use macros there all the
time, which is why I was picked on to help with this little task. :)

The macro is:

Sub ColorCircle()
With ActiveWindow.Selection.ShapeRange
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 102, 0)
.Fill.Solid
End With
End Sub

I'm almost positive there is something very obvious I am missing here. Can
anyone help me with this?

Thanks!
Jennifer
 
I was asked to figure out a way to change the background color of some shapes
in a slide show by just clicking on them.

I've got a macro to do that. I've right-clicked on the object and chose
"Action Settings" Under On Click, I picked the name of the macro to run.
Nothing happens.

Now, I am not an expert or even a casual user of Power Point. I don't
really know what I am doing. I do know Excel and use macros there all the
time, which is why I was picked on to help with this little task. :)

The macro is:

Sub ColorCircle()
With ActiveWindow.Selection.ShapeRange
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 102, 0)
.Fill.Solid
End With
End Sub

You can't select anything in Slide Show view, so any macro that depends on the
selection will fail. Try something like this:

Sub ColorCircle(oSh as Shape)
With oSh
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 102, 0)
.Fill.Solid
End With
End Sub
 
you can also do this without any code at all!

Apply an emphasis custom animation (change fill colour).

Double click the entry in the custom anim. pane and in timing set a trigger
(click on itself)
 
Steve,

Thank you for your reply! But it didn't work. Actually, it might have
worked if it was ever called, but ...

I tried the code you posted and made sure the macro was selected in the
"Action Settings". I placed a breakpoint at the beginning of the sub and it
was never called.

Is there something special I need to do to get the macro to be called?

Thanks,
Jennifer
 
If you use Steve's code, then the shape you want to change should have
the macro "Color Circle" assigned for its Action Settings. When you click
on the shape in Slide Show View (not in Edit/Normal View), it should
change the color of the shape. Are your macro settings set to Medium or
Low?
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
Interesting. I don't usually use breakpoints, so I decided to check it
out. First I ran the procedure with no breakpoints, and it worked
perfectly (as seen by the color change of the shape). Next I set a
breakpoint and ran again. The breakpoint did nothing. Perhaps, you should
try putting a MsgBox instead of a breakpoint for testing purposes. Right
after the Sub line, put

MsgBox "About to change the color."

It worked for me.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
Thanks for the thought on the security settings. I don't normally think of
that unless I'm in Excel. :) They were set to high. I changed to Medium,
but it still didn't work. Nor at Low either. The macro is assigned to an
action setting. But still no go. I put in a message box as well, and that
didn't pop up either.

Thanks for the suggestions! It is appreciated.

Jennifer
 
Is the circle being clicked? (ie do you get the pointy fingure/hand icon when
you hover over it) I've had a problem recently with part of a transparent png
covering the shape to be clicked. The code works fine for me BTW
 
Once you change the macro setting, you have to exit out of the
PowerPoint, and open the presentation again. Also be sure you choose
Enable Macros when asked. An easy test to see if macros are properly
enabled is to hit Alt-F8 and click once on your macro. If the Run button
is grayed out, macros are not enabled. If the Run button is not grayed
out, macros are enabled.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
Steve,

Thank you for your reply! But it didn't work. Actually, it might have
worked if it was ever called, but ...

Forgot to mention:

You need to select the shape, rightclick, choose Action Settings and choose Run
Macro: Color Circle.
 
Back
Top