VBA ppt

Bonjour à tous,

j'espère que vous allez bien.

Je cherche à copier/coller un slide PPT depuis VBA.

Le code que j'ai créé ajoute des slides, mais n'en copie pas.

Voici mon code :

Option Explicit

Sub creationPresentation()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Dim ppt As PowerPoint.Application, Pres As PowerPoint.Presentation, Chemin As String, an As Worksheet, pptLayout As CustomLayout, pptSlide As Slide, i As Integer
Dim gr As Worksheet
Dim oSh As Variant, oSh2 As Variant

Set an = Sheets("TEMPLATE")
Set gr = Sheets("Graphes")

Chemin = "Z:\Prod\PREZ_Presentations\2019_CODIR_DROM"

Set ppt = CreateObject("PowerPoint.Application")
ppt.Visible = True

'Ouverture du template
Set Pres = ppt.Presentations.Open(Chemin & "\CODIR DROM.pptx")
Set pptLayout = Pres.Slides(2).CustomLayout

For i = 3 To 4
    Set pptSlide = Pres.Slides.AddSlide(i, pptLayout)
Next

'Slide 1
'Collage du tableau de chiffres
an.Range("C5:X25").Copy
Set oSh = Pres.Slides(2).Shapes.PasteSpecial(ppPasteEnhancedMetafile)

With oSh
   ' Set position:
  .Left = 5
  .Top = 80
   ' Set size:
  .Height = 800
  .Width = 950
End With

'Titre
With an
    .Activate
    .Shapes.Range(Array("titre1")).Select
End With

Selection.Copy
Set oSh = Pres.Slides(2).Shapes.PasteSpecial(ppPasteEnhancedMetafile)

With oSh
   ' Set position:
  .Left = 80
  .Top = 5
End With

With gr
 .Activate
 .Shapes.Range(Array("Chart 2", "Chart 3", "Chart 4", "Chart 5")).Select
End With

Selection.Copy
Set oSh = Pres.Slides(3).Shapes.PasteSpecial(ppPasteEnhancedMetafile)

'Pres.Save

'ppt.Quit

End Sub

Merci d'avance.

Vlad

Bonjour Vlad,

Pour aider, peux-tu joindre l'EXCEL ?

Rechercher des sujets similaires à "vba ppt"