VBA PowerPoint 슬라이드를 이름으로 선택하십시오
-
21-12-2019 - |
문제
이름으로 슬라이드를 선택하려고합니다.윤곽선을 통해 제목을 추가했습니다.아래는 작동하지 않는 코드입니다."Slide Collection에서 찾을 수없는 아이템 아이다 호"
ActivePresentation.Slides("Idaho").Select
. 해결책
슬라이드의 이름과 제목 자리 표시 자의 텍스트는 서로 다른 것과 아무 것도하지 않습니다.
이름을 바꾸지 않으면 프레젠테이션의 첫 번째 슬라이드가 "slide1", 두 번째 "슬라이드 2"등이 지정됩니다.
제목 텍스트="IDAHO"가있는 슬라이드를 찾는 방법을 구체적으로 필요로하는 경우 프레젠테이션의 모든 슬라이드를 검색하고 기준을 충족하는 첫 번째 슬라이드를 반환하는 기능을 작성해야합니다.예 :
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
. 다른 팁
오래된 질문을 되 찾으십시오. 그러나 나는 이것을 던지고 싶었습니다.
ActivePresentation.Slides("MySlideName").Select
가 작동하지 않는 것이 가능하지만, 이것은 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
.
이것은 물론 "myslidename"이라는 슬라이드가 있다고 가정합니다.코드는 Item MySlideName not found in the Slides collection.
오류 (err.number = -2147188160
)를 정상적으로 처리해야합니다.
제휴하지 않습니다 StackOverflow