Text box macro

  • Thread starter Thread starter Juliette
  • Start date Start date
J

Juliette

Hi,
I am not using VB a lot with PPT so appologize if my question is very easy...
My understanding is that each time we create a text box in a presentation,
it has a unique ID whatever slide it is in. I would like to refer to this
text box, without refering to a specific slide.

Currently I have something like:
Set sh = PowerPoint.ActivePresentation.Slides(5).Shapes("Text box 2")
sh.TextFrame.TextRange.Text = "Test"

And I would like to be able to refer to "Text box 2" without refering to
"slide(5)". I would like to avoid using "slideid" as well to make my life
easier. Is that any possible?

Many thanks for your help
 
Juliette,

Well, it might not be easy, but it might be. There are three ways to
refer to a slide:

(1) By slide number
(2) By slide name
(3) The current slide

You can do (1) just like you have done:

ActivePresentation.Slides(#)

Then you get the shapes on that slide with:

ActivePresentation.Slides(#).Shapes(#)

For (2), you do the exact same thing except that you replace the slide
number with the slide name in quotes:

ActivePresentation.Slides("MyIndexSlide")

For (3), you can refer to the current slide:

ActivePresentation.SlideShowWindow.View.Slide

Then you can refer to shapes on the current slide with:

ActivePresentation.SlideShowWindow.View.Slide.Shapes(#)

This works for most of my purposes because I either want to refer to
some other slide (by name or number) or the same slide. I often have
several similar slides and want to manipulate the same shape on
different slides. For example, if I have a quiz, I might want to
manipulate a smiley face shape that gets hidden and shown. There is a
smiley face on each slide (perhaps, named "SmileyFace") that I can
manipulate use option 3 above so it hides or shows the smiley face on
the current slide.

For some information about naming shapes and slides, you can refer to
Example 8.7 on my site:

http://www.PowerfulPowerPoint.com/

Just click on "Examples by Chapter" and "Chapter 8."

--David
 
Back
Top