Save only selected section

gailb
3StarLounger
Posts: 254
Joined: 09 May 2020, 14:00

Save only selected section

Post by gailb »

I have this code which works fine to save a section; however, is it possible to have it simply identify the section of the active slide and simply deduce from there the name of the section? Also, what is the possibility of having this saved section embedded in an email as an attachment?

Code: Select all

Sub chexSections()
    Dim tempPres    As Presentation
    Dim strName     As String: strName = InputBox("Name of Section")
    Dim L           As Long
    Dim s As Long

    If ActivePresentation.SectionProperties.count > 1 Then
        ActivePresentation.SaveCopyAs Environ("TEMP") & "temp.pptx", ppSaveAsOpenXMLPresentation
        Set tempPres = Presentations.Open(Environ("TEMP") & "temp.pptx")
        For L = 1 To ActivePresentation.SectionProperties.count
            If UCase(ActivePresentation.SectionProperties.Name(L)) = UCase(strName) Then
                Exit For
            End If
        Next L
    End If
    For s = ActivePresentation.SectionProperties.count To 1 Step -1
        If s > L Or s < L Then ActivePresentation.SectionProperties.Delete (s), True
    Next s
    tempPres.SaveAs "C:\Users\gailb\OneDrive\Desktop\" & strName & ".pptx"
End Sub

User avatar
HansV
Administrator
Posts: 78493
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Save only selected section

Post by HansV »

The section index of the active slide is

ActiveWindow.View.Slide.sectionIndex

Does that help?
Best wishes,
Hans

gailb
3StarLounger
Posts: 254
Joined: 09 May 2020, 14:00

Re: Save only selected section

Post by gailb »

Yes Hans, that indeed did it. Thanks.