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
| Option Explicit
Private Sub DeleteAllSheets()
Dim Ws As Worksheet
For Each Ws In ThisWorkbook.Worksheets
If Ws.Name <> Feuil1.Name And Ws.Name <> Feuil2.Name Then
Application.DisplayAlerts = False
Ws.Delete
Application.DisplayAlerts = True
End If
Next Ws
End Sub
Private Sub DelOle()
Dim oOle As OLEObject
For Each oOle In Worksheets(Feuil2.Name).OLEObjects
Feuil2.Shapes(oOle.Name).Delete
Next oOle
End Sub
Private Sub InsertionPDF(ByVal sNomFichier As String)
DeleteAllSheets
DelOle
Application.ScreenUpdating = False
With Feuil2
.Activate
.Range("B2").Select
.OLEObjects.Add Filename:=sNomFichier
End With
Application.ScreenUpdating = True
End Sub
Sub SelFichierPDF()
Dim Fichier As Variant
ChDir ThisWorkbook.Path
Fichier = Application.GetOpenFilename("Fichiers PDF (*.pdf), *.pdf", Title:="Sélection PDF pour Insertion Excel")
If Fichier = False Then Exit Sub
DoEvents
InsertionPDF Fichier
End Sub |