Identifying the Notes frame in PPT VBA, etc.

G

Gregg Roberts

Hi,

In PPT 2007 I'm writing a macro to auto-hide or auto-unhide slides in a
LARGE (600+-slides) preso based on tags that the user can manually add to the
Notes page. One tag is special, forcing the macro not to unhide a slide that
otherwise would be unhidden. The macro is turning to be more complicated than
it needs to be. If I knew the best/simplest way to tell that a given Shape is
a Notes page, I could simplify a couple of aspects of it. Currently I'm
checking whether the Shape currently being processed has a textframe, and if
so, checking to see whether the textframe has the exact text of the tag I'm
looking for:

While ShapeIndex <= ShapeCt And Not MainTagFound
If .Shapes(ShapeIndex).HasTextFrame Then
If InStr(1, .Shapes(ShapeIndex).TextFrame.TextRange.Text,
"hide4brownbag45") > 0 Then
MainTagFound = True
End If
End If
ShapeIndex = ShapeIndex + 1
Wend

But this is different from knowing whether the Shape currently being
processed is a Notes page. Theoretically the tag text could appear anywhere
on the slide, which is really a user error I'd like to ignore. Also, I'd like
to be able to auto-insert a certain tag into the Notes page even if it
currently doesn't contain any tags. So I really need the "right"
identification method instead of this kludge.
 
J

John Wilson

Hi

Are these really tags or just text?

To find a tag attached to a shape on a notes page

Sub notestag()
Dim onote As Shape
Dim osld As Slide
For Each osld In ActivePresentation.Slides
For Each onote In osld.NotesPage.Shapes
If onote.Tags("tagname") = "value of tag" Then MsgBox _
"I'm found > tag on Slide " _
& osld.SlideIndex & ": Notes page"
Next onote
Next osld
End Sub

If its just text you will need to adjust accordingly.
 
G

Gregg Roberts

You guys are great. Let me try these things out and get back with you.

It's just text, not a real tag. I'll check with my user and see if he's OK
with using real tags.
 
G

Gregg Roberts

Let's get the terms sorted out first. A shape is never a notes page. A
notes
page is, for all practical purposes, a slide. It's a container for shapes, not
a shape itself. Each slide has a companion NotesPage.

Somehow my code below works in spite of that.
As far as tagging, it might be more reliable to tag the notespage itself rather
than tagging shapes (which might not be there in the first place or which the
user might delete).

' to tag the notes page for slide 1
With ActivePresentation.Slides(1)
With .NotesPage
.Tags.Add "MyTagName", "MyTagValue"
End With
End With

But it's the user who needs to do most of the tagging. Is there a way to add
a tag to something (a shape or a notes page, I don't care which) "manually,"
without VBA? I don't see any such option on the Insert ribbon, nor does the
Help system tell me anything about this when I search for "tag."

Gregg
 
J

John Wilson

Tags can only be added using code. This can be an advantage as they are not
easily read or deleted!

It's not difficult to produce an add in that will add a tag at the click of
a button.

If you just want the user to add some special text to the notes this should
help (special text here is mytagtext)

Sub readtag()
Dim osld As Slide
Dim oshp As Shape
Dim strTag As String
Const strSpecial As String = "mytagtext" ' change
For Each osld In ActivePresentation.Slides
For Each oshp In osld.NotesPage.Shapes
If oshp.Type = msoPlaceholder Then
If oshp.PlaceholderFormat.Type = ppPlaceholderBody Then
If InStr(oshp.TextFrame.TextRange, strSpecial) > 0 Then
strTag = strTag & vbCrLf & "Slide " & osld.SlideIndex
End If 'tag
End If 'placeholder
End If 'type
Next oshp
Next osld
If strTag = "" Then strTag = "No Tags found!"
MsgBox "Tags found on : " & strTag
End Sub
--
Amazing PPT Hints, Tips and Tutorials

http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
_______________________________
 

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