Slide numbers and VBA programming

G

georges

HI,

Using powerpoint XP

I have used VBA statements such as:

ActivePresentation.Slides(29).Shapes("Picture 10").Visible = False
ActivePresentation.Slides(31).Shapes("Picture 11").Visible = False

to turning slidegraphics visibility property on and off as necessary.

problem: doing this I am "bounded" by absolute slidenumber that
changes as I insert slides at the beginning.

Each slide has different numer of graphics taht have to be shown and
hided at user commands.

Is there a VBA way to circumvent the absolute slidenumber problem ?

Sincerely,

georges (new to VBA in powerpoint but very interested).
 
G

Guest

You can access slides in two different ways: using a slide number or accessing the current slide

For example, you can do what you tried

ActivePresentation.Slides(29).Shapes("Picture 10").Visible = Fals

This will access "Picture 10" on slide 29. Alternatively, you can access that shape on the CURRENT slide

ActivePresentation.SlideSlideShowWindow.View.Slide.Shapes("Picture 10").Visible = Fals

Both have their advantages. A final idea is to use the current slide's number to do something like access the next slide

myNum = ActivePresentation.SlideShowWindow.View.Slide.SlideInde

This will give you the current slides index (the location in the presentation) so you could use myNum for the current slide or myNum + 1 for the next slide or myNum -1 for the previous slide, etc.

ActivePresentation.Slides(myNum + 1).Shapes("Picture 10").Visible = Fals

I have examples like this in my book Powerful PowerPoint for Educators. You can get information about the book at

http://www.loyola.edu/education/PowerfulPowerPoint

--Davi

David M. Marcovitz, Ph.D
Director of Graduate Programs in Educational Technolog
Loyola College in Marylan
Author of _Powerful PowerPoint for Educators_

----- georges wrote: ----

HI

Using powerpoint X

I have used VBA statements such as

ActivePresentation.Slides(29).Shapes("Picture 10").Visible = Fals
ActivePresentation.Slides(31).Shapes("Picture 11").Visible = Fals

to turning slidegraphics visibility property on and off as necessary.

problem: doing this I am "bounded" by absolute slidenumber tha
changes as I insert slides at the beginning

Each slide has different numer of graphics taht have to be shown an
hided at user commands

Is there a VBA way to circumvent the absolute slidenumber problem ?

Sincerely

georges (new to VBA in powerpoint but very interested).
 
G

georges

dear Bill,

thank You very much. I switched to the FindbySlideID to identify my
Slides independently of the index and this works perfect.

Fortunately that each slide has this unique Id number and name.

Thanks again !

Georges
 
S

Steve Rindsberg

ActivePresentation.Slides(29).Shapes("Picture 10").Visible = False
ActivePresentation.Slides(31).Shapes("Picture 11").Visible = False

to turning slidegraphics visibility property on and off as necessary.

problem: doing this I am "bounded" by absolute slidenumber that
changes as I insert slides at the beginning.

Each slide has different numer of graphics taht have to be shown and
hided at user commands.

If you name the slides and the shapes, it becomes much simpler:

ActivePresentation.Slides("George").Shapes("Steve").Visible = False
 
G

Guest

Sorry, I misread the question. Of course, the naming slide thing is the way to go for what you wanted to do. While you're at it, you can name the pictures and other objects too. I'll have to get those examples from Chapter 8 on my Web site soon
--Davi

----- David M. Marcovitz wrote: ----

You can access slides in two different ways: using a slide number or accessing the current slide

For example, you can do what you tried

ActivePresentation.Slides(29).Shapes("Picture 10").Visible = Fals

This will access "Picture 10" on slide 29. Alternatively, you can access that shape on the CURRENT slide

ActivePresentation.SlideSlideShowWindow.View.Slide.Shapes("Picture 10").Visible = Fals

Both have their advantages. A final idea is to use the current slide's number to do something like access the next slide

myNum = ActivePresentation.SlideShowWindow.View.Slide.SlideInde

This will give you the current slides index (the location in the presentation) so you could use myNum for the current slide or myNum + 1 for the next slide or myNum -1 for the previous slide, etc.

ActivePresentation.Slides(myNum + 1).Shapes("Picture 10").Visible = Fals

I have examples like this in my book Powerful PowerPoint for Educators. You can get information about the book at

http://www.loyola.edu/education/PowerfulPowerPoint

--Davi

David M. Marcovitz, Ph.D
Director of Graduate Programs in Educational Technolog
Loyola College in Marylan
Author of _Powerful PowerPoint for Educators_

----- georges wrote: ----

HI

Using powerpoint X

I have used VBA statements such as

ActivePresentation.Slides(29).Shapes("Picture 10").Visible = Fals
ActivePresentation.Slides(31).Shapes("Picture 11").Visible = Fals

to turning slidegraphics visibility property on and off as necessary.

problem: doing this I am "bounded" by absolute slidenumber tha
changes as I insert slides at the beginning

Each slide has different numer of graphics taht have to be shown an
hided at user commands

Is there a VBA way to circumvent the absolute slidenumber problem ?

Sincerely

georges (new to VBA in powerpoint but very interested).
 
G

georges

S
If you name the slides and the shapes, it becomes much simpler:

ActivePresentation.Slides("George").Shapes("Steve").Visible = False

Indeed. I used this method after learning the difference between
index, Id, slidenumber and slidename. Now I will look into slide tag
property to see how this can be used.

Thanks for all the support.

Georges
 
S

Steve Rindsberg

David M. said:
Sorry, I misread the question. Of course, the naming slide thing is the
way to go for what you wanted to do.

In this case, probably so, but you've posted some really good stuff here.
Thanks!

While you're at it, you can name the pictures and other objects too. I'll
have to get those examples from Chapter 8 on my Web site soon.
--David

----- David M. Marcovitz wrote: -----

You can access slides in two different ways: using a slide number or accessing the current slide.

For example, you can do what you tried:

ActivePresentation.Slides(29).Shapes("Picture 10").Visible = False

This will access "Picture 10" on slide 29. Alternatively, you can
access that shape on the CURRENT slide:ActivePresentation.SlideSlideShowWindow.View.Slide.Shapes("Picture
10").Visible = False
Both have their advantages. A final idea is to use the current
slide's number to do something like access the next slide:
myNum = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex

This will give you the current slides index (the location in the
presentation) so you could use myNum for the current slide or myNum + 1 for
the next slide or myNum -1 for the previous slide, etc.:
ActivePresentation.Slides(myNum + 1).Shapes("Picture 10").Visible = False

I have examples like this in my book Powerful PowerPoint for
Educators. You can get information about the book at:
 
S

Steve Rindsberg

If you name the slides and the shapes, it becomes much simpler:
Indeed. I used this method after learning the difference between
index, Id, slidenumber and slidename. Now I will look into slide tag
property to see how this can be used.

Tags can be applied to presentations, slides, shapes ... you name it.
Multiple tags are no problem.

Very useful!

For directly accessing a slide or shape, naming is more effective, I think.
You can ask PPT for a reference to the Slide name George but to find the slide
with the Name tag = "George", you'd have to iterate through the whole slides
collection looking at the Name tags of each.

Ah, and you can have only one shape named "George" on a slide, but you can have
multiple shapes with Name tag = "George"; another important difference.
 
D

David M. Marcovitz

Steve's right: All shapes have unique names unless you copy-paste a
shape with a given name, . When you copy-paste a shape that has a name
you provided, the new shape will have the same name as the one you
copied.

- Chirag

PowerShow - View multiple shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
My Chapter 8 examples are up on my Web site, and they include a simple
example for finding the names of slides, setting the names of slides,
finding the names of shapes, and setting the names of shapes.

http://www.loyola.edu/education/PowerfulPowerPoint/Chapter8Examples.html

Look for Example 8-7.

--David

--
David M. Marcovitz, Ph.D.
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
S

Steve Rindsberg

Steve's right: All shapes have unique names unless you copy-paste a shape
with a given name, . When you copy-paste a shape that has a name you
provided, the new shape will have the same name as the one you copied.

Yes, a nasty little bug, that one.

It shouldn't do that, and it'll throw an error if you try to give two shapes
the same name in code (as it *should* do). Problem is, it'll also throw an
error if you have two shapes of the same name (courtesy of PPT's mistake) and
try to rename one.
 

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