Et sinon j'ai cette fct qui marche pour powerpoint comment l'adapter pour excel ?
Sub SavePDFAsPng(sPathToPDF As String, sPathToPNG As String)
Dim MonPPT As New PowerPoint.Application
Dim oPres As Presentation
' Height/Width are hardcoded here
' You could get trickier and bring the PDF into any presentation
' once to get its proportions, delete it, set the slide size to the same
' proportions, then re-insert the PDF
Dim sngWidth As Single
Dim sngHeight As Single
sngWidth = 841.875
sngHeight = 595.25
Set MonPPT = CreateObject("PowerPoint.Application")
MonPPT.Visible = True ' Indispensable, sinon il ne peut pas ouvrir de fichier (Erreur)
Set oPres = MonPPT.Presentations.Add
With oPres
With .PageSetup ' set it to 8.5x11
.SlideHeight = sngHeight ' 11in * 72 points per inch
.SlideWidth = sngWidth
End With
.Slides.AddSlide 1, .SlideMaster.CustomLayouts(1)
With .Slides(1)
Set oSh = .Shapes.AddOLEObject(0, 0, sngWidth, sngHeight, , sPathToPDF)
Call .Export(sPathToPNG, "PNG") '"PNG" pour ping, "JPG" pour jpeg, "BMP" ...
End With
.Saved = False
MonPPT.Quit
Set MonPPT = Nothing
End With
End Sub
Sub TestSavePDFAsPng()
Call SavePDFAsPng("NomFichierpdf.pdf", "NomFichierpng.png")
End Sub