Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

XL 2019 copy filtered range to jpeg

duplaly

XLDnaute Occasionnel
Hi
I'm trying to find the good way to transform that vba code for a fixed range.

'Create JPG file of the range
'Only enter the Sheet name and the range address
MakeJPG = CopyRangeToJPG("Rapport", "A1:H108")

to a filtered range

'Only the visible cells in the selection
Dim lr As Long
lr = Sheets("Registre").Cells(Application.Rows.Count, 1).End(xlUp).Row
Set Rng = Sheets("Rapport").Range("A1:H" & lr).SpecialCells(xlCellTypeVisible)

Any help!!

Thanks!
 

kiki29

XLDnaute Barbatruc
Salut, qqch comme ceci, à adapter à ton contexte.

VB:
Option Explicit

Sub Export()
Dim oWs As Worksheet
Dim oRng As Range
Dim oChrtO As ChartObject
Dim lWidth As Long, lHeight As Long

    Set oWs = ActiveSheet
    Set oRng = oWs.Range("B2:H11")

    oRng.CopyPicture xlScreen, xlPicture
    lWidth = oRng.Width
    lHeight = oRng.Height

    Set oChrtO = oWs.ChartObjects.Add(Left:=0, Top:=0, Width:=lWidth, Height:=lHeight)

    oChrtO.Activate
    With oChrtO.Chart
        .Paste
        .Export Filename:=ThisWorkbook.Path & "\" & "Range2JPEG.jpg", Filtername:="JPG"
    End With

    oChrtO.Delete
End Sub
 
Dernière édition:
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…