Bonjour a tous,
J'ai un probleme avec mon code VBA pour creer des presentation sur PowerPoint. Mon code va chercher un template specifique dans mon bureau.
Puis je veux selectionner la slide 2 et copier coller un range d'excel. Mais le probleme est que je n'arrive pas a selectionner les slides et j'ai une erreur 429:"ActiveX component can't create object"
Quelqu'un aurai une idee?
Merci d'avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Option Explicit Sub CreatePowerPoint() Dim mySlide As PowerPoint.Slide Dim myShapeRange As PowerPoint.Shape Dim oPA As PowerPoint.Application Dim oPP As PowerPoint.Presentation Dim strTemplate As String Dim rng As Range strTemplate = "C:\Users\290866\Desktop\vba\PPT\Template.potx" Set oPA = New PowerPoint.Application oPA.Visible = msoTrue oPA.Presentations.Open strTemplate, untitled:=msoTrue If Not mySlide Is Nothing Then Set mySlide = Nothing If Not oPP Is Nothing Then Set oPP = Nothing If Not oPA Is Nothing Then Set oPA = Nothing Err_PPT: If Err <> 0 Then MsgBox Err.Description Err.Clear Resume Next End If Set rng = ThisWorkbook.Sheets("Credit Recommendation").Range("B2:N59") set mySlide = ActivePresentation.Slides(1) rng.Copy mySlide.Shapes.PasteSpecial (ppPasteBitmap) Set myShapeRange = mySlide.Shapes(mySlide.Shapes.Count) myShapeRange.LockAspectRatio = msoFalse myShapeRange.Left = 20 myShapeRange.Top = 80 myShapeRange.Height = 400 myShapeRange.Width = 680 Application.CutCopyMode = False End Sub
Partager