Can I use VBA to force Powerpoint to open the most recent Sharepoint version of a file?

Viewed 19

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 appears to work, except for one thing: it 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 seems to help, but this 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) can ensure that the slides are taken from the most recent version, major or minor, of the target presentations.

Not sure if it matters or not, but the Sharepoint site is associated with Teams (although I always use Sharepoint directly).

Current code below; thanks for reading.

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
0 Answers
Related