Code to affect multiple slides

  • Thread starter Keri in Vermont
  • Start date
K

Keri in Vermont

In PowerPoint 2003, I have a Custom Action Button on slide 7. When that
button (lets call it “1â€) is pressed a text box appears (lets call it "A").
Slide 10 has a Custom Action button that makes a text box appear (lets call
it "B"). What I need, is for when the Custom Action button on slide 7 is
pressed (“1â€), not only is "A" activated, so is "B" (there will also be "C",
"D" etc.). I KNOW I have to write code to do this. I have a Macro set that
when I press the button (“1â€), “B†“C†and “D†should appear. They don’t.
The code I have is:
ActivePresentation.Slides(7).Shapes(53).Visible = True [aka “Bâ€]
ActivePresentation.Slides(10).Shapes(51).Visible = True [aka “Câ€]
ActivePresentation.Slides(13).Shapes(51).Visible = True But they
didn’t work

I then tried:
ActivePresentation.Slides(7).Shapes(53).AddEffect = msoAnimEffectAppear
ActivePresentation.Slides(10).Shapes(51).AddEffect = msoAnimEffectAppear
ActivePresentation.Slides(13).Shapes(51).AddEffect = msoAnimEffectAppear
But they didn’t work either.

Could someone please assist me with the proper code to get this to work?
 
D

David M. Marcovitz

=?Utf-8?B?S2VyaSBpbiBWZXJtb250?=
In PowerPoint 2003, I have a Custom Action Button on slide 7. When
that button (lets call it “1â€) is pressed a text box appears (lets
call it "A"). Slide 10 has a Custom Action button that makes a text
box appear (lets call it "B"). What I need, is for when the Custom
Action button on slide 7 is pressed (“1â€), not only is "A"
activated, so is "B" (there will also be "C", "D" etc.). I KNOW I
have to write code to do this. I have a Macro set that when I press
the button (“1â€), “B†“C†and “D†should appear. They
don’t. The code I have is:
Your code is correct, assuming that you really have shape 53 on slide 7,
shape 51 on slide 10, and shape 51 on slide 13. You might be better off
naming those shapes. If you are using PPT 2007, you can name them
without code, but if you are using 2003 or earlier, you can use the code
in example 8.7 on my site to name them:

http://www.PowerfulPowerPoint.com/

Just click on "Examples by Chapter" and "Chapter 8." I'm guessing that
your shape numbers changed on you (lots of things can do that) as you
seem to have over 50 shapes per slide. When you use the code to name the
shapes, you can change the lines to something like this

ActivePresentation.Slides(7).Shapes("My Wonderful Star Shape").Visible =
True

You could even use the code to name the slides and replace the slide
numbers with names.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
ActivePresentation.Slides(7).Shapes(53).Visible = True [aka
“Bâ€] ActivePresentation.Slides(10).Shapes(51).Visible = True
[aka “Câ€] ActivePresentation.Slides(13).Shapes(51).Visible =
True But they didn’t work

I then tried:
ActivePresentation.Slides(7).Shapes(53).AddEffect =
msoAnimEffectAppear ActivePresentation.Slides(10).Shapes(51).AddEffect
= msoAnimEffectAppear
ActivePresentation.Slides(13).Shapes(51).AddEffect =
msoAnimEffectAppear
But they didn’t work either.

Could someone please assist me with the proper code to get this to
work?
 
K

Keri in Vermont

I have read that - it doesn't help. I have 36 different shapes I would have
to go in and rename. I have to have this done by Thursday, in addition to
ALL my other duties. Why doesn't my code work AS IS?

David M. Marcovitz said:
=?Utf-8?B?S2VyaSBpbiBWZXJtb250?=
In PowerPoint 2003, I have a Custom Action Button on slide 7. When
that button (lets call it “1â€Â) is pressed a text box appears (lets
call it "A"). Slide 10 has a Custom Action button that makes a text
box appear (lets call it "B"). What I need, is for when the Custom
Action button on slide 7 is pressed (“1â€Â), not only is "A"
activated, so is "B" (there will also be "C", "D" etc.). I KNOW I
have to write code to do this. I have a Macro set that when I press
the button (“1â€Â), “B†“C†and “D†should appear. They
don’t. The code I have is:
Your code is correct, assuming that you really have shape 53 on slide 7,
shape 51 on slide 10, and shape 51 on slide 13. You might be better off
naming those shapes. If you are using PPT 2007, you can name them
without code, but if you are using 2003 or earlier, you can use the code
in example 8.7 on my site to name them:

http://www.PowerfulPowerPoint.com/

Just click on "Examples by Chapter" and "Chapter 8." I'm guessing that
your shape numbers changed on you (lots of things can do that) as you
seem to have over 50 shapes per slide. When you use the code to name the
shapes, you can change the lines to something like this

ActivePresentation.Slides(7).Shapes("My Wonderful Star Shape").Visible =
True

You could even use the code to name the slides and replace the slide
numbers with names.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
ActivePresentation.Slides(7).Shapes(53).Visible = True [aka
“Bâ€Â] ActivePresentation.Slides(10).Shapes(51).Visible = True
[aka “Câ€Â] ActivePresentation.Slides(13).Shapes(51).Visible =
True But they didn’t work

I then tried:
ActivePresentation.Slides(7).Shapes(53).AddEffect =
msoAnimEffectAppear ActivePresentation.Slides(10).Shapes(51).AddEffect
= msoAnimEffectAppear
ActivePresentation.Slides(13).Shapes(51).AddEffect =
msoAnimEffectAppear
But they didn’t work either.

Could someone please assist me with the proper code to get this to
work?
 
D

David M. Marcovitz

The likely answer is that what you think is shape 51 is no longer shape
51. Using shape numbers is fine when you are dealing with a few shapes
on a slide, but it can be very problematic for dealing with MANY shapes
on a slide. If you delete one, all the shapes change numbers. If you
change the order of a shape, the shpaes change numbers.

If your shape numbers are really what you think they are, here are some
other possible issues:

(1) Is your code working at all? You might have some unrelated error in
your code that causes none of it to work.
(2) Do you have any funky characters in your file name (I believe that
file names that include an exclamation point won't run VBA code).
(3) Do the shapes hide and/or show when go to Normal/Edit View. On
occasion, certain things will cause the slide not to refresh properly in
slide show view. This has been particularly problematic with animated
GIFs on a page.

I'm grasping at straws here because I think the real culprit is that
your shape numbers aren't what you think they are. Try this. In Normal
View, select a shape and run this macro to find out what its number
really is:

Sub WhatsMyNumber()
MsgBox "The number of the selected shape is " _
& ActiveWindow.Selection.ShapeRange(1).ZOrderPosition
End Sub

--David
--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/

=?Utf-8?B?S2VyaSBpbiBWZXJtb250?=
I have read that - it doesn't help. I have 36 different shapes I
would have to go in and rename. I have to have this done by Thursday,
in addition to ALL my other duties. Why doesn't my code work AS IS?

David M. Marcovitz said:
=?Utf-8?B?S2VyaSBpbiBWZXJtb250?=
In PowerPoint 2003, I have a Custom Action Button on slide 7. When
that button (lets call it “1â€Â) is pressed a text box
appears (lets call it "A"). Slide 10 has a Custom Action button
that makes a text box appear (lets call it "B"). What I need, is
for when the Custom Action button on slide 7 is pressed
(“1â€Â), not only is "A" activated, so is "B" (there will
also be "C", "D" etc.). I KNOW I have to write code to do this. I
have a Macro set that when I press the button (“1â€Â),
“B†“C†and “D†should appear.
They don’t. The code I have is:
Your code is correct, assuming that you really have shape 53 on slide
7, shape 51 on slide 10, and shape 51 on slide 13. You might be
better off naming those shapes. If you are using PPT 2007, you can
name them without code, but if you are using 2003 or earlier, you can
use the code in example 8.7 on my site to name them:

http://www.PowerfulPowerPoint.com/

Just click on "Examples by Chapter" and "Chapter 8." I'm guessing
that your shape numbers changed on you (lots of things can do that)
as you seem to have over 50 shapes per slide. When you use the code
to name the shapes, you can change the lines to something like this

ActivePresentation.Slides(7).Shapes("My Wonderful Star
Shape").Visible = True

You could even use the code to name the slides and replace the slide
numbers with names.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
ActivePresentation.Slides(7).Shapes(53).Visible = True
[aka “Bâ€Â]
ActivePresentation.Slides(10).Shapes(51).Visible = True
[aka “Câ€Â]
ActivePresentation.Slides(13).Shapes(51).Visible =
True But they didn’t work

I then tried:
ActivePresentation.Slides(7).Shapes(53).AddEffect =
msoAnimEffectAppear
ActivePresentation.Slides(10).Shapes(51).AddEffect =
msoAnimEffectAppear
ActivePresentation.Slides(13).Shapes(51).AddEffect =
msoAnimEffectAppear
But they didn’t work either.

Could someone please assist me with the proper code to get this to
work?
 
J

John Wilson

Hi Keri

As David says your problem is very likely to be the use of shape numbers.

Imagine that you have 6 shapes on a slide

The shape at the back is Shapes(1) and the shape at the front would be
Shapes(6) If you send a shape to back / front / forwards etc or delete a
shape then everything changes! It is VERY unlikely that Shapes(51) on one
slide is the same shhape as Shapes(51) on another. You will need to identify
the shapes with either a name or a tag using the code David provided. I hear
your anxiety about getting it complete but really this is the only way!

If you are really stuck I have a couple of work experience girls at the
moment who are raising money for a charity in Tanzania. They would get it
done for a donation to their charity (they're 16 but they know what they're
doing with vba!)
http:www.JustGiving.com/technologytrish
--
-------------------------------------------
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk


Keri in Vermont said:
I have read that - it doesn't help. I have 36 different shapes I would have
to go in and rename. I have to have this done by Thursday, in addition to
ALL my other duties. Why doesn't my code work AS IS?

David M. Marcovitz said:
=?Utf-8?B?S2VyaSBpbiBWZXJtb250?=
In PowerPoint 2003, I have a Custom Action Button on slide 7. When
that button (lets call it “1â€Â) is pressed a text box appears (lets
call it "A"). Slide 10 has a Custom Action button that makes a text
box appear (lets call it "B"). What I need, is for when the Custom
Action button on slide 7 is pressed (“1â€Â), not only is "A"
activated, so is "B" (there will also be "C", "D" etc.). I KNOW I
have to write code to do this. I have a Macro set that when I press
the button (“1â€Â), “B†“C†and “D†should appear. They
don’t. The code I have is:
Your code is correct, assuming that you really have shape 53 on slide 7,
shape 51 on slide 10, and shape 51 on slide 13. You might be better off
naming those shapes. If you are using PPT 2007, you can name them
without code, but if you are using 2003 or earlier, you can use the code
in example 8.7 on my site to name them:

http://www.PowerfulPowerPoint.com/

Just click on "Examples by Chapter" and "Chapter 8." I'm guessing that
your shape numbers changed on you (lots of things can do that) as you
seem to have over 50 shapes per slide. When you use the code to name the
shapes, you can change the lines to something like this

ActivePresentation.Slides(7).Shapes("My Wonderful Star Shape").Visible =
True

You could even use the code to name the slides and replace the slide
numbers with names.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
ActivePresentation.Slides(7).Shapes(53).Visible = True [aka
“Bâ€Â] ActivePresentation.Slides(10).Shapes(51).Visible = True
[aka “Câ€Â] ActivePresentation.Slides(13).Shapes(51).Visible =
True But they didn’t work

I then tried:
ActivePresentation.Slides(7).Shapes(53).AddEffect =
msoAnimEffectAppear ActivePresentation.Slides(10).Shapes(51).AddEffect
= msoAnimEffectAppear
ActivePresentation.Slides(13).Shapes(51).AddEffect =
msoAnimEffectAppear
But they didn’t work either.

Could someone please assist me with the proper code to get this to
work?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top