vba powerpoint 按名称选择幻灯片 [英] vba powerpoint select a slide by name

查看:136
本文介绍了vba powerpoint 按名称选择幻灯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按名称选择幻灯片.我通过大纲添加了一个标题.下面是不起作用的代码.在幻灯片集合中找不到项目爱达荷州"

I am trying to select a slide by name. I have added a title via the outline. below is the code that is not working. "item Idaho not found in the slide collection"

ActivePresentation.Slides("Idaho").Select

推荐答案

幻灯片的名称和标题占位符中的文本彼此毫无关系.

The slide's name and the text in the title placeholder nave nothing to do with one another.

除非您已重命名,否则演示文稿中的第一张幻灯片将命名为Slide1",第二张幻灯片将命名为Slide2",依此类推.

Unless you've renamed it, the first slide in the presentation will be named "Slide1", the second "Slide2" and so on.

如果您特别需要一种方法来定位标题文本 = "Idaho" 的幻灯片,您需要编写一个函数来搜索演示文稿中的所有幻灯片并返回它找到的第一个符合您条件的幻灯片.例如:

If you specifically need a way to locate the slide whose title text = "Idaho", you'd need to write a function to search all the slides in the presentation and return the first one it finds that meets your criteria. For example:

Sub TestMe()
    Dim oSl As Slide
    Set oSl = FindSlideByTitle("idaho")

    If Not oSl Is Nothing Then
        MsgBox "Found your title on slide " & CStr(oSl.SlideIndex)
    End If

End Sub
Function FindSlideByTitle(sTextToFind As String) As Slide
    Dim oSl As Slide

    For Each oSl In ActivePresentation.Slides
        With oSl.Shapes.Title.TextFrame
            If .HasText Then
                If UCase(.TextRange.Text) = UCase(sTextToFind) Then
                    Set FindSlideByTitle = oSl
                End If
            End If
        End With
    Next

End Function

这篇关于vba powerpoint 按名称选择幻灯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆