In PowerPoint 2007/2010 you can use CustomXMLParts
as sort of a tag. Here's a demo:
Sub SetSlideMasterTag()
Dim ap As Presentation
Set ap = ActivePresentation
''#------------------------
Dim slideMasterCustomerData As CustomerData
Set slideMasterCustomerData = ap.SlideMaster.CustomerData
''#------------------------
Dim slideMasterCustomXMLPart As CustomXMLPart
Set slideMasterCustomXMLPart = slideMasterCustomerData.Add
slideMasterCustomXMLPart.LoadXML ("<Tag><Item>SlideMaster</Item></Tag>")
''#------------------------
Dim slideMasterTag As String
slideMasterTag = slideMasterCustomXMLPart.Id
''#------------------------
Debug.Print slideMasterTag
Debug.Print ap.CustomXMLParts.SelectByID(slideMasterTag).XML
''#------------------------
ap.CustomDocumentProperties.Add Name:="SlideMasterTag", LinkToContent:=False, _
Type:=msoPropertyTypeString, Value:=slideMasterTag
End Sub
Sub RetrieveSlideMasterTag()
Dim ap As Presentation
Set ap = ActivePresentation
''#------------------------
Dim slideMasterTag As String
slideMasterTag = ap.CustomDocumentProperties.Item("SlideMasterTag").Value
Debug.Print slideMasterTag
''# Is this the right slide master?
If Not ap.SlideMaster.CustomerData(slideMasterTag) Is Nothing Then
Debug.Print "Found you, you little bugger!"
End If
End Sub
A couple of things to remember:
- You have to maintain the
slideMasterTag
between sessions.
Probably the best place to do this is
in the CustomDocumentProperties
,
hence the RetrieveSlideMasterTag
routine. It is highly unlikely that
an end user would go into here.
- If you didn't want to do add this to
CustomDocumentProperties
, you would
just need to query all
CustomXMLParts
using XPath for your
XML.
- The code above doesn't do any error
or validation checking. You'll need
to see create code to ensure that
there is not already a tag called
slideMasterTag
.