Discussion:
Change background color of shape through macro
(too old to reply)
Jennifer
2006-05-24 22:00:01 UTC
Permalink
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
Steve Rindsberg
2006-05-24 22:52:28 UTC
Permalink
Post by 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. :)
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



-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Jennifer
2006-05-25 14:13:02 UTC
Permalink
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
Post by Steve Rindsberg
Post by 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. :)
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
Sub ColorCircle(oSh as Shape)
With oSh
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 102, 0)
.Fill.Solid
End With
End Sub
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
David M. Marcovitz
2006-05-25 14:39:37 UTC
Permalink
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/
Post by Jennifer
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
Post by Steve Rindsberg
Post by 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. :)
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
Sub ColorCircle(oSh as Shape)
With oSh
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 102, 0)
.Fill.Solid
End With
End Sub
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
David M. Marcovitz
2006-05-25 14:50:44 UTC
Permalink
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/
Subject: Re: Change background color of shape through macro
Newsgroups: microsoft.public.powerpoint
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/
Post by Jennifer
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
Post by Steve Rindsberg
Post by 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. :)
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
Sub ColorCircle(oSh as Shape)
With oSh
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 102, 0)
.Fill.Solid
End With
End Sub
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Jennifer
2006-05-25 16:09:02 UTC
Permalink
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
Post by David M. Marcovitz
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/
Post by Jennifer
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
Post by Steve Rindsberg
Post by 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. :)
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
Sub ColorCircle(oSh as Shape)
With oSh
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 102, 0)
.Fill.Solid
End With
End Sub
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
trish
2006-05-25 16:13:02 UTC
Permalink
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
Post by Jennifer
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
Post by David M. Marcovitz
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/
Post by Jennifer
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
Post by Steve Rindsberg
Post by 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. :)
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
Sub ColorCircle(oSh as Shape)
With oSh
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 102, 0)
.Fill.Solid
End With
End Sub
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
David M. Marcovitz
2006-05-25 16:23:27 UTC
Permalink
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/
Post by Jennifer
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
Post by David M. Marcovitz
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
Steve Rindsberg
2006-05-25 20:00:40 UTC
Permalink
Post by Jennifer
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.
Post by Jennifer
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
Post by Steve Rindsberg
Post by 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. :)
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
Sub ColorCircle(oSh as Shape)
With oSh
.Fill.Visible = msoTrue
.Fill.ForeColor.RGB = RGB(255, 102, 0)
.Fill.Solid
End With
End Sub
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================

trish
2006-05-25 09:27:01 UTC
Permalink
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)
Post by 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. :)
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
Continue reading on narkive:
Loading...