PDA

View Full Version : Custom slide show filter for slide sorter view



thecatim
08-04-2021, 12:33 AM
Please help me....I have a few custom slide shows and wanted to use that as a filter to view these slides in slide sorter mode?

would slide tags work and how?

I found the vba in the attached txt file that will identify the slide ID's and although it works fine it seems not the best way to reference by ID's

Paul_Hossler
08-04-2021, 07:20 AM
Attaching a presentation PPTM as an example would make it easier to see what you want

John Wilson
08-04-2021, 02:16 PM
Custom Shows are always referenced by ID as this allows the slides to be moved without breaking the custom show.

It is posssible to show the current slide index but this will be unreliable if you reorganise the presentation in any way.


Sub GetListofCustomShows(ByVal Pres As Presentation, _
ByRef CustomShows As Collection)

Dim NS As NamedSlideShow

Dim I As Long
Dim S As String
Dim osld As Slide

With Pres.SlideShowSettings

For Each NS In .NamedSlideShows
S = NS.Name + ": "
For I = 1 To NS.Count
Set osld = Pres.Slides.FindBySlideID(NS.SlideIDs(I))
S = S & CStr(osld.SlideIndex) & ", "
Next
S = Left(S, Len(S) - 2)
CustomShows.Add S
Next
End With
End Sub






Sub Test()
Dim Msg As String
Dim CustomShows As Collection
Dim I As Long


Set CustomShows = New Collection
GetListofCustomShows ActivePresentation, CustomShows
For I = 1 To CustomShows.Count
Msg = Msg + CustomShows(I) + vbCrLf
Next
MsgBox Msg, vbInformation Or vbOKOnly, "Custom Shows List"


Set CustomShows = Nothing
End Sub

thecatim
08-05-2021, 03:24 PM
Many thanks for the info that I will check out.

Are there any good references or tutorials as to how tags really work...after a bit of experimentation I realised that tags is just a JSON pair so I could have multiple tags with the tag name & also the value as unique to do some really powerfull stuff. The std powerpoint methods to manage slides is just so lacking and poor....if the custom slide show could filter the slides on the slide sorter view it would be so great (oh yeah and create a new presentation from the custom slide shows) but MS never really ask their users do they.

Looking into the tags it seems a very powerfull method so I am trying to learn more about it so please let me know if you know of any good in depth articles.

Below is what I got working well now:

Sub SetTheTagToSelectedSlides()
Dim osld As Slide
Dim sTagName As String
Dim sTagValue As String
Dim TagValueToSlides As Variant


'change to suit
sTagName = InputBox("Enter slide tag name")
TagValueToSlides = InputBox("Enter slide tag value")


'check for selection
If ActiveWindow.Selection.Type = ppSelectionNone Then GoTo errhandler


'add tags
For Each osld In ActiveWindow.Selection.SlideRange
osld.Tags.Add sTagName, TagValueToSlides
Next osld
Exit Sub
errhandler:
MsgBox "You need to select slides first!"
End Sub


Sub ExtractSlidesWithTags()
Dim TagNameToSlides As String
Dim TagValueToSlides As String
Dim AnythingFound As Boolean
Dim currentPresentation As Presentation
Dim newPresentation As Presentation
Dim s As Slide


TagNameToSlides = InputBox("Tag name of slides to extract")
TagValueToSlides = InputBox("Tag Value of slides to extract")


' Save reference to current presentation
Set currentPresentation = Application.ActivePresentation


' Save reference to current slide
'Set currentSlide = Application.ActiveWindow.View.Slide


' Add new Presentation and save to a reference
Set newPresentation = Application.Presentations.Add


' Add the current slide master
'ActivePresentation.Designs.Load "G:\Cloud\CATIM\CATIM SharePoint - Documents\Admin\Templates\Documents\CATIM org wide v7.potx"
ActivePresentation.ApplyTemplate "G:\Cloud\CATIM\CATIM SharePoint - Documents\Admin\Templates\Documents\CATIM org wide v7.potx"




For Each Slide In currentPresentation.Slides
If Slide.Tags(TagNameToSlides) = TagValueToSlides Then
Slide.Copy
' Paste it in new Presentation
newPresentation.Slides.Paste
AnythingFound = True
Wait (1)
End If
Next




If AnythingFound = True Then
newPresentation.SaveAs (currentPresentation.Path & "" & TagNameToSlides & "_Extract.pptm")
Else
MsgBox "No slides have that tag named"
End If


End Sub


Public Sub Wait(Seconds As Double)
Dim endtime As Double
endtime = DateTime.Timer + Seconds
Do
WaitMessage
DoEvents
Loop While DateTime.Timer < endtime
End Sub






Sub SlideMasterCleanup()
Dim i As Integer
Dim j As Integer
Dim oPres As Presentation
Set oPres = ActivePresentation
On Error Resume Next
With oPres
For i = 1 To .Designs.Count
For j = .Designs(i).SlideMaster.CustomLayouts.Count To 1 Step -1
.Designs(i).SlideMaster.CustomLayouts(j).Delete
Next
Next i
End With


End Sub

thecatim
08-05-2021, 03:42 PM
One last thing...I managed to get the slides extracted and saved with what I required accept it is not copying the slide background graphic that is really odd. I have seen that one can add by VBA the background from a folder etc however I just really want the slide completely as is with all content, styling and background. There seems no info on copying the background over on google?