1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| Sub Test()
'Declaration variables
Dim oPPT As New PowerPoint.Application
Dim oPres As PowerPoint.Presentation
Dim oSlide As PowerPoint.Slide
Dim oShp As PowerPoint.Shape
Dim oTextRg As PowerPoint.TextRange
Dim oTrouve As PowerPoint.TextRange
Dim Recherche$: Recherche = "******" 'definition du mot a chercher (remplacer les *)
'ouverture du PPT
Set oPres = oPPT.Presentations.Open("ici le chemin vers le PPT")
'Pour chaque Slide
For Each oSlide In oPres.Slides
'Pour chaque objet tracés
For Each oShp In oSlide.Shapes
'Si c'est une zone de texte
If oShp.HasTextFrame Then
'je cherche et boucle a l'interieur
Set oTextRg = oShp.TextFrame.TextRange
Set oTrouve = oTextRg.Find(Findwhat:=Recherche)
While Not (oTrouve Is Nothing)
With oTrouve
Debug.Print Recherche & " est trouvé dans la zone de texte nommée """ & oShp.Name & """ sur le slide " & oSlide.SlideNumber & " en position " & .Start
Set oTrouve = oTextRg.Find(Findwhat:=Recherche, After:=.Start + .Length - 1)
End With
Wend
End If
Next
Next
fin:
'liberation des variables avec close de la presentation et quit de l'appli PPT
oPres.Close
oPPT.Quit
Set oPPT = Nothing
Set oPres = Nothing
Set oSlide = Nothing
Set oShp = Nothing
Set oTextRg = Nothing
End Sub |
Partager