Identify each slide so its source can be tracked
Problem
You have a lot of different presentations and you often copy slides from one presentation to another. You want to be able to track where a slide came from originally and what other presentations it's appeared in.
Solution
The macro below will help. The code here will:
- "TAG" each slide in the presentation with the presentation's name. It will only tag each slide once per presentation but if the slide's copied into a new presentation and the macro runs again, it will append the name of the new presentation to the tag so you track what presentations the slide's been in previously.
- Show you the tag (ie, list of presentations) for the currently selected slide
- Optionally, clear all the tags from all slides in the presentation.
This is just a start. You might want to:
- Add more tags that e.g. track the SlideIndex (ie, slide number) of the slide.
- Add the ability to clear the tag(s) from just the current slide instead of all of them.
- Create a report for all the slides in the presentation.
As one of our other PPT MVPs says: "It's only code."
Sub ID_The_Slides()
Dim oSl As Slide
Dim sPresName As String
Dim sTagName As String
sPresName = ActivePresentation.FullName
sTagName = "Provenance"
For Each oSl In ActivePresentation.Slides
With oSl.Tags
' Is it already tagged as coming from this presentation?
' If so, the last part of the tag will be the
' the presentation name; no need to tag it again
If Not Right$(.Item(sTagName), Len(sPresName)) = sPresName Then
' if no tag at all, just add the presentation name
If Len(.Item(sTagName)) = 0 Then
oSl.Tags.Add sTagName, sPresName
Else ' or tack pres name to end of existing tag
oSl.Tags.Add sTagName, _
Trim(oSl.Tags(sTagName)) _
& "|" _
& sPresName
Debug.Print .Item(sTagName)
End If
End If
End With
Next
End Sub
Sub Clear_The_Tags()
Dim oSl As Slide
Dim sTagName As String
sTagName = "Provenance"
For Each oSl In ActivePresentation.Slides
oSl.Tags.Add sTagName, ""
Next
End Sub
Sub Show_Source()
' Where'd this slide come from?
Dim sMsg As String
Dim aMsg As Variant
Dim x As Long
Dim sTagName As String
sTagName = "Provenance"
With ActiveWindow.Selection.SlideRange(1)
If Len(.Tags(sTagName)) > 0 Then
aMsg = Split(.Tags(sTagName), "|")
For x = 0 To UBound(aMsg)
sMsg = sMsg & aMsg(x) & vbCrLf
Next
End If
End With
If Len(sMsg) > 0 Then
MsgBox sMsg
Else
MsgBox "No source information available"
End If
End Sub
See How do I use VBA code in PowerPoint? to learn how to use this example code.