我正在尝试将定义的Excel范围导出为本地图像文件(PNG)(图像:“摘要”标签:P1:AI92上的“ Print_Area”)。该程序运行良好,但是当我打开文件时,所有的想象都是空白
这是我正在使用的编码:

Sub _Daily_Mail()

Dim Rango7 As Range
Dim Archivo As String
Dim Imagen As Chart
Dim Result As Boolean

Set Rango7 = Sheets("Summary").Range("P2:AI92")   ' Summary
Sheets("Summary").Select

 With Rango7
      .CopyPicture Appearance:=xlScreen, Format:=xlPicture
       Set Imagen = Rango7.Parent.ChartObjects.Add(33, 39, .Width, .Height).Chart
    End With

Imagen.Paste
Imagen.ChartArea.Border.LineStyle = 0
Imagen.ChartArea.Width = Imagen.ChartArea.Width * 3
Imagen.ChartArea.Height = Imagen.ChartArea.Height * 3

Imagen.export "C:\Users\mely\Documents\Imagenes_POS\Informe1.png", filtername:="PNG"
Imagen.Parent.Delete
Set Imagen = Nothing


When I open the file

最佳答案

在Excel 2016中,您需要在粘贴操作之前使用.Activate命令。
例:

Set rng = Range("A1:C1")

With rng
    .CopyPicture xlPrinter, xlPicture

    Set oChart = ActiveSheet.ChartObjects.Add(.Left, .Top, 1920, 1080)

    oChart.Activate

    With oChart.Chart
        .ChartArea.Border.LineStyle = 0
        .Paste
        .Export Filename:="C:\File.jpg", Filtername:="jpg"
        .Parent.Delete
    End With
End With

10-06 01:59