vba powerpoint select a slide by name

后端 未结 2 1128
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 17:19

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\"



        
2条回答
  •  臣服心动
    2021-01-21 17:42

    Reviving an old question, but I wanted to throw this in.

    While it's possible that ActivePresentation.Slides("MySlideName").Select doesn't work, this does work for me in PPT 2010:

    Dim PPTObj As PowerPoint.Application
    Set PPTObj = New PowerPoint.Application
    Dim PPTClinic As PowerPoint.Presentation
    Set PPTClinic = PPTObj.Presentations.Open(FileName:="Your File Name Here")
    PPTClinic.Slides("MySlideName").Select
    

    This, of course, assumes that there is a slide named "MySlideName". Your code will have to deal with gracefully handling the Item MySlideName not found in the Slides collection. error (err.number = -2147188160).

提交回复
热议问题