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 41 42 43 44 45 46 47 48
| Sub TestPowerPoint()
' On déclare une variable de type Application PowerPoint
Dim ppt As PowerPoint.Application
Set ppt = CreateObject("PowerPoint.Application")
ppt.Visible = True ' Indispensable, sinon il ne peut pas ouvrir de fichier (Erreur)
' On crée maintenant un objet Presentation
Dim Pres As PowerPoint.Presentation
' Et on lui dit de quelle présentation il s'agit :
Dim wkb As Workbook
Set wkb = ThisWorkbook
Dim sheet As Worksheet
Dim ordre As Range
Set sheet = wkb.Sheets("Feuil1")
Set ordre = sheet.Range("ordre")
k = 1
While ordre.Offset(k, -2).Value <> ""
k = k + 1
Wend
k = k - 1
Dim strRepertoire As String
Dim strFichier As String
For j = 1 To k
If ordre.Offset(j, -1).Value = "ppt" Or ordre.Offset(j, -1).Value = "pptx" Then
strRepertoire = "C:\documents\s821451\Desktop\ODJ"
strFichier = ordre.Offset(j, -2).Value
Set Pres = ppt.Presentations.Open(Filename:=strRepertoire & "\" & strFichier)
Dim objsld2 As Slide
Set objsld2 = Pres.Slides(2)
Dim texte_C1 As Variant
texte_C1 = objsld2.Shapes("Rectangle 3").TextFrame.TextRange.Text
ordre.Offset(j, 0).Value = texte_C1
Pres.Close
End If
Next j
End Sub |
Partager