Export selection vers png

Bonjour,

J’aimerais savoir s’il est possible de pouvoir créer une macro VBA pour que ça m’exporte ma selection en format .png en me demandant, avant d’exporter, le nom que je voudrais mettre pour le fichier

Merci d’avance pour votre réponse.

Cordialement

à force de recherche j’ai trouver ce code qui fonctionne à merveille :

Public Function ExporterPlageCommeImage2(PlageAExporter As Range, LignesDeGrille As Boolean, FichierImage As String)

On Error GoTo FonctionErreur

LignesDeGrilleOriginal = ActiveWindow.DisplayGridlines
ActiveWindow.DisplayGridlines = LignesDeGrille

PlageAExporter.CopyPicture Appearance:=xlScreen, Format:=xlPicture

With ActiveSheet.ChartObjects.Add(Left:=PlageAExporter.Left, Top:=PlageAExporter.Top, _
Width:=PlageAExporter.Width, Height:=PlageAExporter.Height)
.Name = "ExportImage"
.Activate
End With
ActiveChart.Paste
ActiveSheet.ChartObjects("ExportImage").Chart.Export FichierImage
ActiveSheet.ChartObjects("ExportImage").Delete

ActiveWindow.DisplayGridlines = LignesDeGrilleOriginal

Exit Function
FonctionErreur:
MsgBox « Une erreur est survenue… »
End Function
Sub ExempleExportImage()

Application.ScreenUpdating = False
On Error GoTo ExportErreur

Dim Plage As Range
Dim FichierImage As String
Dim AfficherGrilles As Boolean

Set Plage = Workbooks(« NOM DU FICHIER.xlsm »).Sheets(« NOM DE L’ONGLET »).Range(« VOTRE SELECTION »).Cells
FichierImage = « VOTRE EMPLACEMENT\NOM DU FICHIER.jpg »
AfficherGrilles = True
Workbooks(« VOTRE FICHIER.xlsm »).Activate
ExportFichier = ExporterPlageCommeImage2(Plage, AfficherGrilles, FichierImage)

Application.ScreenUpdating = True
Exit Sub
ExportErreur:
MsgBox « Une erreur est survenue… »
Application.ScreenUpdating = True
End Sub

Hello,

Merci pour ton partage :slight_smile:

Bonne journée a toi

1 « J'aime »

Ce sujet a été automatiquement fermé après 30 jours. Aucune réponse n’est permise dorénavant.