Macro Insertion Image depuis Excel
bonjour à tous,
j'avance (péniblement, mais bon) sur une macro excel qui génère un pptx, avec des données, et je veux également insérer l'image correspondant à ces données dans mon slide
j'ai fait dans le pptx un tableau afin de recevoir chaque donnée dans des cellules et je veux dans la dernière ligne du tableau insérer une image
mais je sèche sur la syntaxe à mettre :
.Cell(2, 1).Shape.Pictures.Insert = Tablo(x, 4) 'chemin de la photo
j'obtiens l'erreur 438 "propriété ou méthode non gérée par cet objet"
Code:
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
|
With Sheets("sheet1")
Tablo = Range("A2:D" & Range("A65000").End(xlUp).Row).Value
End With
Set objPPT = CreateObject("Powerpoint.Application")
objPPT.Visible = True
Set objPres = objPPT.Presentations.Open(ThisWorkbook.Path & "\note1.pptx")
objPres.SaveAs ThisWorkbook.Path & "\test.ppt"
For i = 1 To UBound(Tablo)
If Tablo(i, 3) = 0 And Tablo(i, 4) = 0 Then
Set objSld = objPres.Slides(1).Duplicate
For Each objShp In objSld.Shapes
If objShp.HasTable Then
With objShp.Table
x = x + 1
.Cell(1, 1).Shape.TextFrame.TextRange.Text = Tablo(x, 1) 'nom
.Cell(1, 2).Shape.TextFrame.TextRange.Text = Tablo(x, 2) 'prénom
.Cell(1, 3).Shape.TextFrame.TextRange.Text = Tablo(x, 3) 'âge
.Cell(2, 1).Shape.Pictures.Insert = Tablo(x, 4) 'chemin de la photo
End With
End If
Next
End If
Next
objPres.Slides(1).Delete
objPres.Save
objPres.Close
End Sub |
ma feuille est composée comme suit :
col A = nom
col B = prénom
col C = âge
col D = chemin de l'image
quelqu'un a-t-il une piste pour résoudre ce problème ?
d'avance merci !