PPT: Display total # of pages for handouts

C

Cody

I'm trying to print handouts (with 6 slides per page) that will include a
footer that displays the total number of handout pages. So, for example, if
there are 14 slides, the handouts would show that there are 3 pages.

Using this code works for displaying the total number of pages for the
entire presentation:

With ActivePresentation.Slides
AddOne = IIf((.Count Mod 6) = 0, 0, IIf((.Count Mod 6) < 5, 1, 0))
TotalPages = (.Count \ 6) + AddOne
End With

However, I was wondering if anyone knows a way to handle print ranges. So if
I select a group of something like 8 slides to print, is there a way that I
can get it to display 2 as the total number of pages?

Any help would be greatly appreciated.
 
S

Steve Rindsberg

I'm trying to print handouts (with 6 slides per page) that will include a
footer that displays the total number of handout pages. So, for example, if
there are 14 slides, the handouts would show that there are 3 pages.

Using this code works for displaying the total number of pages for the
entire presentation:

With ActivePresentation.Slides
AddOne = IIf((.Count Mod 6) = 0, 0, IIf((.Count Mod 6) < 5, 1, 0))
TotalPages = (.Count \ 6) + AddOne
End With

However, I was wondering if anyone knows a way to handle print ranges. So if
I select a group of something like 8 slides to print, is there a way that I
can get it to display 2 as the total number of pages?

Any help would be greatly appreciated.

You might start by modifying your current code to use a variable instead of
.Count to begin with.

Set the variable value to .Count if printing the entire presentation.
If printing a range, you'll need to parse the range string to calculate the
number of pages, then pass that to your routine in the var instead of .Count

Possibiliity: use Split to break up the print range string on the ","
character. For each element in the resulting array

If Instr(Element,"-") > 0 then ' it's a range
' parse out the beginning and ending numbers
' increment lNumSlides by absolute value of end - begin + 1
' because ranges might be "3-5" or "3-3" or even "5-3"
Else ' it's a single slide, so
lNumSlides = lNumSlides + 1
End If

You might also want to factor out hidden slides, depending on whether you're
allowing them to print or not.
 
C

Cody

Thanks for your help so far.

That makes sense, but I'm really not sure how to write the rest of the code
to do it. Do you think you could give me some more tips?
 
S

Steve Rindsberg

Thanks for your help so far.

That makes sense, but I'm really not sure how to write the rest of the code
to do it. Do you think you could give me some more tips?

Here's an example of how to parse the print range. Just wrote it and gave it a
quick test, but if it doesn't work perfectly we offer a double your money back
guarantee.

Sub PrintRangeCount()

Dim sRange As String
Dim aRange() As String
Dim x As Long
Dim lPageCount As Long
Dim lStart As Long
Dim lEnd As Long

sRange = "1,2,3,4-8,12-10"

aRange = Split(sRange, ",")

lPageCount = 0

For x = 0 To UBound(aRange)
If InStr(aRange(x), "-") > 0 Then
' it's a range

' where does it start and end?
lStart = CLng(Mid$(aRange(x), 1, InStr(aRange(x), "-") - 1))
lEnd = CLng(Mid$(aRange(x), InStr(aRange(x), "-") + 1))

' a forward or backward range?
lPageCount = lPageCount + Abs(lEnd - lStart) + 1

Else
' it's a single page
lPageCount = lPageCount + 1
End If

Next ' array element

MsgBox lPageCount

End Sub
 
C

Cody

Nevermind. I got it to work. It's not exactly what you were describing, but
I think it'll work for all that I need it for.

Here's what I did, just in case anyone else wants to know:

If ActivePresentation.PrintOptions.Ranges.Count > 0 Then
With ActivePresentation.PrintOptions.Ranges.Item(1)
NumSlides = Abs(.End - .Start) + 1
MsgBox (NumSlides)
AddOne = IIf((NumSlides Mod 6) = 0, 0, IIf((NumSlides Mod 6) <
5, 1, 0))
MsgBox (AddOne)
TotalPages = (NumSlides \ 6) + AddOne
MsgBox (TotalPages)
End With
Else
With ActivePresentation.Slides
AddOne = IIf((.Count Mod 6) = 0, 0, IIf((.Count Mod 6) < 5, 1, 0))
TotalPages = (.Count \ 6) + AddOne
End With
End If

Thanks again for your assistance.
 
C

Cody

Didn't see this post before my previous reply. I'll try it out and see if I
can make it work.

Thanks!
 
S

Steve Rindsberg

Nevermind. I got it to work. It's not exactly what you were describing, but
I think it'll work for all that I need it for.

That's why I love this place. You showed me a new trick I had no idea about, .Ranges
Sweet
 

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