Reputation: 11
I have a macro-enabled presentation that aims to use an InsertFromFile
command to copy a single slide from each of a number of other target presentations held in the same SharePoint location into the master.
The code seems to draw the slide from some previous version of the target presentation. Getting the code to open the target presentation before giving the InsertFromFile
command still only gets the slides from a more recent version, not the most recent version.
The SharePoint library uses major and minor versions, but it doesn't look like the most recent major version is used.
I am looking for a way for VBA to ensure that the InsertFromFile
command (or an alternative method) gets the slides from the most recent version, major or minor, of the target presentations.
The SharePoint site is associated with Teams (although I always use SharePoint directly).
Option Explicit
Sub Consolidate()
Dim pptTMOReport As Presentation
Dim strCharterReport As String
Dim strFolderPath As String
Dim intCharter As Integer
Dim intSlideCount As Integer
'Set variables
Set pptTMOReport = ActivePresentation
strFolderPath = pptTMOReport.Path
'Remove previous Charter Report slides
If pptTMOReport.Slides.Count <= 3 Then GoTo CheckCharter
intSlideCount = pptTMOReport.Slides.Count - 3
For intCharter = 1 To intSlideCount
If pptTMOReport.Slides.Count <= 3 Then Exit For
pptTMOReport.Slides(pptTMOReport.Slides.Count - 1).Delete
Next intCharter
CheckCharter:
For intCharter = 1 To 6 'Cycle 6 times (there are 6 target presentations)
strCharterReport = strFolderPath & "/Charter " & intCharter & " Report.pptx"
pptTMOReport.Slides.InsertFromFile strCharterReport, pptTMOReport.Slides.Count - 1, 2, 2 'Insert slide 2 from the target presentation as the second last slide in the master
Next intCharter
pptTMOReport.Slides(1).Shapes("txtDate").TextFrame.TextRange.Text = "Updated " & Format(Now, "d MMMM yyyy hh:mm")
pptTMOReport.SlideMaster.Shapes("txtDate").TextFrame.TextRange.Text = "Updated " & Format(Now, "dd/mm/yyyy")
End Sub
Upvotes: 1
Views: 122