不再可以导出图像

时间:2018-10-15 13:32:25

标签: excel

自从转换为Excel 2016以来,该代码不再起作用。一旦这样做,我就得到了带有正确图像尺寸的白色图像。有人知道原因吗?

Sub BildExportShape(shExport As Shape)
    Dim chDiagramm As ChartObject
    Application.ScreenUpdating = False
    shExport.CopyPicture Appearance:=xlScreen, Format:=xlPicture
    Set chDiagramm = Tabelle2.ChartObjects.Add(0, 0, shExport.Width, shExport.Height)
    With chDiagramm.Chart
        .Paste
        .Export Filename:="H:\Signatur\Wappen.jpg", FilterName:="JPG" ' andere Grafikformate sind möglich
    End With
    chDiagramm.Delete
    Set chDiagramm = Nothing
    Set shExport = Nothing
    Application.ScreenUpdating = True
End Sub

1 个答案:

答案 0 :(得分:0)

尝试不禁用屏幕更新,我相信它给我带来了问题,因此我必须不禁用屏幕更新。

            Call AhorroMemoria(False)
            Imagen.CopyPicture xlScreen, xlBitmap
            With wsM.ChartObjects.Add(Imagen.Left - Imagen.Left * 0.15, Imagen.Top - Imagen.Top * 0.15, _
                Imagen.Width - Imagen.Width * 0.15, Imagen.Height - Imagen.Height * 0.15)
                .Activate
                wsM.Shapes("Gráfico 1").Line.Visible = msoFalse
                .Chart.Paste
                .Chart.Export wb.Path & "\" & Servicio & Contador & ".jpg", "JPG"
            End With
            Call AhorroMemoria(True)

这是我的功能AhorroMemoria:

Sub AhorroMemoria(isOn As Boolean)

    Application.Calculation = IIf(isOn, xlCalculationManual, xlCalculationAutomatic)
    Application.EnableEvents = Not (isOn)
    Application.ScreenUpdating = Not (isOn)
    ActiveSheet.DisplayPageBreaks = False

End Sub