Specifying a slide range

L

Lisa

How can I specify a range of slides without listing each slide in the desired
range?

For example the following works to specify slides 1 through 5:
For Each objSlide In ActivePresentation.Slides.Range(Array(1, 2, 3, 4,
5))

However, sometimes the desired range will include 50 or more slides, and
listing them individually seems silly and time consuming... Therefore I'd
like to write something like the following (which doesn't work):
For Each objSlide In ActivePresentation.Slides.Range(Array(1 To 5))
 
L

Lisa

Thank you for your response, Glenna. I've reviewed the info at the link
below, and do not see anything that points me to how I can specify the range
without listing all the individual slides within the range.

As far as I can tell, the examples given in the article are analogous to:
ActivePresentation.Slides.Range(Array(1, 2, 3, 4, 5))
(Slides listed individually either by index or name)

What I'm hoping to do is something analogous to:
ActivePresentation.Slides.Range(Array(1 To 5))
(Slide range defined with a beginning and end of the range, inclusive of all
slides between beginning and end)

Am I missing something in the article?

Thanks again,
LM
 
S

Shyam Pillai

Lisa,
If the slide range is going to be sequential you can simple loop thru the
slide from the starting slide to the last slide.
For I = 10 to 60
Debug.Print Activepresentation.slides(I).Name
Next

The Range method is extremely handy when you want to work with non
contiguous slides based on an array selection. But you need to populate the
array with values.

Dim MyArr(1 to 3) as Long
Dim oSld as Slide
MyArr(1)=12
MyArr(2)=22
MyArr(3)=32

For Each oSld In ActivePresentation.Slides.Range(MyArr)
Debug.Print oSld.Name
Next


--
Regards,
Shyam Pillai

Image Importer Wizard
http://skp.mvps.org/iiw.htm
 
L

Lisa

Steve and Shyam, thank you both very much -- your guidance helped immensely!

Just in case it's of any use to anybody, below is the code that incorporates
the infor you gave me. It formats text boxes that say "UPDATE REQUIRED" that
are on plopped onto the notes pages in an existing file, changing only those
that are found on the notes pages for slides 3 to 22. A quirky little need --
but variations on the "do it for these contiguous slides" theme will help me
with a bunch of other stuff.

Thanks again!
LM

Sub FormatUpdateTxt
Dim objShape As Shape
Dim nn As Integer
For nn = 3 To 22
For Each objShape In ActivePresentation.Slides(nn).NotesPage.Shapes
If objShape.TextFrame.HasText Then
If objShape.TextFrame.TextRange.Text = "UPDATE REQUIRED" Then
With objShape.Fill
.Solid
.ForeColor.RGB = RGB(0, 0, 255)
End With
Else 'do nothing
End If
Else 'do nothing
End If
Next
Next
End Sub
 

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