PDA

View Full Version : add duplicate page numbers to notes pages



LyPy
07-21-2015, 05:00 PM
I have a unique situation I think can only be solved with VBA code, but I'm just learning and I haven't been able to figure it out. :(

I need to be able to add a page number to the notes page view of a slide, and then add the same page number to the next notes page, but with the letters FG preceding the number. The end result would look like this:
Slide 1 = Notes page 1
Slide 2 = Notes page FG1
Slide 3 = Notes page 2
Slide 4 = Notes page FG2

(This is for training material where each page in the student guide has a corresponding facilitator guide page. I know PPT isn't the best application for this type of thing, but unfortunately, it's not my choice.)

Anyway, is it possible to do this with VBA? I would greatly appreciate any advice!

John Wilson
07-21-2015, 11:58 PM
Try this then:


Sub notepage()
Dim osld As Slide
Dim oNum As Shape
Dim x As Long
For Each osld In ActivePresentation.Slides
For Each oNum In osld.NotesPage.Shapes
If oNum.Type = msoPlaceholder Then
If oNum.PlaceholderFormat.Type = ppPlaceholderSlideNumber Then
If osld.SlideIndex / 2 = osld.SlideIndex \ 2 Then 'it's even do not increment
oNum.TextFrame2.TextRange = "FG" & CStr(x)
Else ' it's odd
'increment number
x = x + 1
oNum.TextFrame2.TextRange = CStr(x)
End If
End If
End If
Next oNum
Next osld
End Sub

LyPy
07-22-2015, 07:01 AM
Thanks for the quick reply! I tried the code you suggested, but it didn't seem to do anything. I'll play with it and see if I can figure out what I'm missing. Thanks for getting me started!


Try this then:


Sub notepage()
Dim osld As Slide
Dim oNum As Shape
Dim x As Long
For Each osld In ActivePresentation.Slides
For Each oNum In osld.NotesPage.Shapes
If oNum.Type = msoPlaceholder Then
If oNum.PlaceholderFormat.Type = ppPlaceholderSlideNumber Then
If osld.SlideIndex / 2 = osld.SlideIndex \ 2 Then 'it's even do not increment
oNum.TextFrame2.TextRange = "FG" & CStr(x)
Else ' it's odd
'increment number
x = x + 1
oNum.TextFrame2.TextRange = CStr(x)
End If
End If
End If
Next oNum
Next osld
End Sub

John Wilson
07-22-2015, 07:21 AM
Did you have the slide number showing on notes pages before you ran the code?

LyPy
07-22-2015, 07:42 AM
No, there are no slide numbers on the Notes pages.

John Wilson
07-22-2015, 08:23 AM
That's the problem
Either add them first In Note Page View
INSERT > Tick Slide Number > Apply to all (This is best)

OR you could try this which should do this in code (ONLY if there are NO numbers at all)


Sub NotesFix()
Dim osld As Slide
Dim x As Long
On Error Resume Next
ActivePresentation.NotesMaster.Shapes.AddPlaceholder (ppPlaceholderSlideNumber)
For Each osld In ActivePresentation.Slides
With osld.NotesPage.Shapes.AddPlaceholder(ppPlaceholderSlideNumber)
.TextFrame.TextRange.InsertSlideNumber
If osld.SlideIndex / 2 = osld.SlideIndex \ 2 Then
.TextFrame2.TextRange = "FG" & CStr(x)
Else
x = x + 1
.TextFrame2.TextRange = CStr(x)
End If
End With
Next osld
End Sub

LyPy
07-22-2015, 08:35 AM
Perfect!! You're a genius! Thank you SO MUCH!!

John Wilson
07-23-2015, 02:52 AM
Pleasure.

LyPy
07-28-2015, 12:38 PM
John,
I hate to ask after all you've done already, but I've been asked to make the page numbering start on the second slide. Could I trouble you for help with that?

John Wilson
07-29-2015, 02:47 AM
can you explain EXACTLY what you need but assuming you mean:

eg Slide 2 Notes page =1
Slide 3 Notes ="FG1"

This should work (make sure numbers are visible before running)


Sub notepage()
Dim osld As Slide
Dim oNum As Shape
Dim x As Long
For Each osld In ActivePresentation.Slides
For Each oNum In osld.NotesPage.Shapes
If oNum.Type = msoPlaceholder Then
If oNum.PlaceholderFormat.Type = ppPlaceholderSlideNumber Then
If osld.SlideIndex / 2 = osld.SlideIndex \ 2 Then 'it's even increment
x = x + 1
oNum.TextFrame2.TextRange = CStr(x)
Else ' it's odd ad "FG"
oNum.TextFrame2.TextRange = "FG" & CStr(x)
End If
'remove slide 1 number
If osld.SlideIndex = 1 Then oNum.Delete
End If
End If
Next oNum
Next osld
End Sub

LyPy
07-29-2015, 08:58 AM
Thank you, thank you, thank you! You're a lifesaver! I actually need it to be 0, FG1, 1, FG2, 2... but I was able to make the necessary change and it works beautifully! You're a wizard! :wizard: