Bonjour,
J'utilise Office 2010. J'ai créé une macro pour rechercher un mot dans un diaporama (23 diapos) et, une fois trouvé en le sélectionnant (hyperlien) il exécute un autre PowerPoint.
Ci-joint le code de la macro :
Private Sub CommandButton1_Click()
'************************************
Dim FlagTrv As Boolean ' si la recherche a trouver un hit
FlagTrv = False
Dim Msg As String ' Message pour informer l'utilisateur
Dim Msg2 As String ' Message pour informer l'utilisateur
Dim Msg3 As String ' Message pour informer l'utilisateur
'************************************************************
Dim reponse$
Dim answer As Integer
Dim sld As Slide
Dim SH As Shape
Dim TR As TextRange
Dim TR2 As TextRange 'Range du texte trouvé
'*******************************************************
' demande la variable à chercher
reponse$ = InputBox("Texte à rechercher", "Formation Excel 2010")
' message d'information
Msg = "Recherche de " & reponse$ & " introuvable"
Msg2 = "Recherche de " & reponse$ & " est terminée"
Msg3 = "Recherche de " & reponse$ & " a été annulée par l'utilistateur"
'
If reponse$ = "" Then Exit Sub
For Each sld In Application.ActivePresentation.Slides
For Each SH In sld.Shapes
If SH.HasTextFrame Then
Set TR = SH.TextFrame.TextRange
Set TR2 = TR.Find(FindWhat:=reponse$, \_
MatchCase:=msoFalse, \_
WholeWords:=msoFalse)
Do Until TR2 Is Nothing
' MsgBox (SLD.SlideNumber)
**sld.Select**
**With TR2**
**.Select**
answer = MsgBox("Appuyez sur Oui pour continuer", vbYesNo, "Recherche en cours")
If answer = vbYes Then
Set TR2 = TR.Find(FindWhat:=reponse$, \_
MatchCase:=msoFalse, \_
WholeWords:=msoFalse, \_
After:=.Start + .Length - 1)
FlagTrv = 1
Else
MsgBox (Msg3)
Exit Sub
End If
End With
Loop
End If
Next SH
Next sld
If FlagTrv = True Then
MsgBox (Msg2)
Else
MsgBox (Msg)
End If
End Sub
Si je teste ce code il fonctionne très bien. Lorsque je l'exécute en mode diaporama il me donne un erreur :
et bloque à la ligne (voir le code en Gras)
Merci à l'avance pour votre aide