1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Option Explicit
#If VBA7 Then
Private Declare ptrsafe Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Long
#Else
Private Declare Function IsClipboardFormatAvailable Lib "user32" (ByVal wFormat As Integer) As Long
#End If
Sub exporte_image()
Dim plage As Range, chart1 As Object, i As Long, mesplage As Variant, hPicAvail As Long
With Sheets("Feuil1")
mesplage = Array("A2:K68", "A69:K180")
Set chart1 = .ChartObjects.Add(0, 0, 1, 1).Chart
For i = 0 To UBound(mesplage)
With CreateObject("htmlfile").parentwindow.clipboardData.clearData("Text"): End With 'on vide le clipboard entre chaque copie pour tester vraiment le available
Set plage = .Range(mesplage(i))
With chart1
With .Parent
.Width = plage.Width: .Height = plage.Height: .Left = plage.Width + 20:
plage.CopyPicture
Do: DoEvents: hPicAvail = IsClipboardFormatAvailable(14): Loop While hPicAvail = 0 'Or (Timer - T) > 1000
.Select |