Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
239 views
in Technique[技术] by (71.8m points)

Powerpoint Macro VBA - Select checkbox for "Slide Image"

I have been trying to modify a useful piece of code created by David Foster some time ago, However the one really useful addition to this code is proving hard to find in the references.

I need to get the macro to make sure that the "Slide Image" checkbox is ticked when it applies the notes master to all slides, as some slides have been "frankensteined" into the project.

I am struggling to find any reference to this checkbox in powerpoint references, any ideas?

Sub DReplaceNotesMaster()
 
' Modified version of code originally posted to
' msnews.microsoft.com public newsgroups by
' David Foster in May of 1999
 
    Dim ctl As CommandBarControl
    Dim oSl As Slide
 
    ' 700 is the control ID for Layout
    Set ctl = CommandBars.FindControl(Id:=700)
    ActiveWindow.ViewType = ppViewNotesPage
 
    If (ctl Is Nothing) Then
        MsgBox "command not available"
        Exit Sub
    End If
 
    For Each oSl In ActivePresentation.Slides
 
        ' go to the current slide
        ActiveWindow.View.GotoSlide (oSl.SlideIndex)
        DoEvents
 
        ' Bring up the dialog
        ctl.Execute
        DoEvents
 
        ' send it the needed keystrokes
        SendKeys "%r{enter}"
        DoEvents
 
    Next
 
End Sub
question from:https://stackoverflow.com/questions/66061367/powerpoint-macro-vba-select-checkbox-for-slide-image

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Oddly, the slide image on a notes page is referred to as a title placeholder. This sub checks every notes page for a placeholder with "Slide Image" in the name and adds it if one is not found. This assumes that someone hasn't used the Selection pane to rename the slide image placeholder. If they have, you'll have to trap the resulting error that displays a message "Invalid request: Slide already contains maximum placeholders of this type".

Sub ShowNotesSlideImage()
    Dim oSlide As Slide
    Dim oShape As Shape
    Dim bTitleFound As Boolean
    
    For Each oSlide In ActivePresentation.Slides
        bTitleFound = False
        For Each oShape In oSlide.NotesPage.Shapes
            If oShape.Type = msoPlaceholder Then
                If InStr(oShape.Name, "Slide Image") > 0 Then
                    bTitleFound = True
                End If
            End If
        Next oShape
        If bTitleFound = False Then
            oSlide.NotesPage.Shapes.AddPlaceholder Type:=ppPlaceholderTitle
        End If
    Next oSlide
End Sub

A handy resource for finding control names and ID numbers is Microsoft's Office 2016 Help Files: Office Fluent User Interface Control Identifiers, a free download.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...