Access/VBA Library


Splits the presentation specified by Filename into several presentations. Each section within this presentation will result in a new presentation. The names of the new files created are the name of the given presentation followed by the sectionindex and its name.


SplitAllSections( Filename )
Name Type Description
Filename String Required. Filemame of the presentation to be split.
Return value

Long : The number of presentations created.

Public Function SplitAllSections(Filename As String) As Long
    Dim CurrentPresentation As Presentation
    Dim TempFilename As String
    Dim SectionIndex As Long
    Dim SectionFilename As String
    Dim SectionFilenameTemp As String
    Dim Location As String
    Dim Counter As Long
    ' Create temporary file to prevent adding to MRU
    TempFilename = CreateTempPresentation(Filename)
    ' Determine output location of the output files
    Location = FSO.GetParentFolderName(Filename)
    With Application_
        Set CurrentPresentation = .Presentations.Open(TempFilename, msoTrue, msoFalse, msoFalse)
        With CurrentPresentation.SectionProperties
            For SectionIndex = 1 To .Count
                ' Split each section into a separate file
                With SplitSection(TempFilename, SectionIndex)
                    ' Get the name of the output file in Windows temp folder
                    SectionFilenameTemp = .FullName
                    ' Move the outputfile from the Windows temp folder to the
                    ' determines location
                    With FSO
                        SectionFilename = Location & "\" & .GetFileName(SectionFilenameTemp)
                        If .FileExists(SectionFilename) Then .DeleteFile SectionFilename
                        .MoveFile SectionFilenameTemp, SectionFilename
                    End With
                    Counter = Counter + 1
                End With
            Next SectionIndex
        End With
    End With
    SplitAllSections = Counter
End Function


See also

  • SplitSection
  • CreateTempPresentation