简体   繁体   English

如何在ppt中选择具有相同自定义布局或包含给定形状或文本的幻灯片?

[英]How to select slides in ppt which have the same custom layout, or contain a given shape or text?

Is there a way in VBA to select all the slides in active ppt doc that use a given custom layout? VBA 中有没有办法选择活动 ppt 文档中使用给定自定义布局的所有幻灯片?

CustomLayout.Name=”1_separator”   
CustomLayout.Index=”1”  

So far, I have played with this idea:到目前为止,我一直在玩这个想法:

For Each CustomLayout In ActivePresentation.SlideMaster.CustomLayouts
If CustomLayout.Name = "1_Separator" Then  
ActivePresentation.Slides.Range.Select  
Exit For  
End If  
Next  
End Sub

However, it selects all the slides in the ppt (not only the ones with ”1_separator”), so it is not what I need.但是,它选择了ppt中的所有幻灯片(不仅是带有“1_separator”的幻灯片),所以它不是我需要的。

My overall aim is to create an automated Table of Contents in ppt, for that I would like to choose particular slides with macro.我的总体目标是在 ppt 中创建一个自动目录,为此我想选择带有宏的特定幻灯片。

Alternatively, I could put a shape or specific text box on the slides, based on which I am going to create a Table of Contents.But I don't know the code for selecting slides with a given shape or text, either.或者,我可以在幻灯片上放置一个形状或特定文本框,我将根据它创建一个目录。但我也不知道选择具有给定形状或文本的幻灯片的代码。

I will be grateful for any help on this.我将不胜感激对此的任何帮助。

Sub SelectSlidesWithGivenCustomLayout()

    Dim slidesToSelect(999)
    Dim currentSlide As Slide
    Dim counter As Integer
    counter = 0

    For Each currentSlide In ActivePresentation.Slides
        If currentSlide.CustomLayout.Name = "1_Separator" Then
            slidesToSelect(counter) = currentSlide.SlideIndex
            counter = counter + 1
        End If
    Next

    ActivePresentation.Slides.Range(slidesToSelect).Select

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM