Excel 在屏幕更新关闭的情况下,将图表对象导出为jpg无法工作

Excel 在屏幕更新关闭的情况下,将图表对象导出为jpg无法工作,excel,vba,export,jpeg,Excel,Vba,Export,Jpeg,好的,我查看了许多不同的论坛,试图找出为什么我的代码不能使用设置为false的屏幕更新。我试图导出一个范围作为一个jpg图像使用图表覆盖,没有什么真正复杂的。但是当我关闭ScreenUpdate时,它只输出一个尺寸正确、名称正确但没有图像的空白图像(全白色),为什么ScreenUpdate与复制到剪贴板的内容有关呢?谢谢您提前提供的帮助 尝试#1(无效): 尝试#2(无效): 尝试#3(与ScreenUpdate=True一起使用): 这对我来说很好: Private Sub CreateLis

好的,我查看了许多不同的论坛,试图找出为什么我的代码不能使用设置为false的屏幕更新。我试图导出一个范围作为一个jpg图像使用图表覆盖,没有什么真正复杂的。但是当我关闭ScreenUpdate时,它只输出一个尺寸正确、名称正确但没有图像的空白图像(全白色),为什么ScreenUpdate与复制到剪贴板的内容有关呢?谢谢您提前提供的帮助

尝试#1(无效):

尝试#2(无效):

尝试#3(与ScreenUpdate=True一起使用):


这对我来说很好:

Private Sub CreateList()

Dim sht As Worksheet
Dim rgExp As Range

    Application.ScreenUpdating = False

    Set sht = Sheet1

    Set rgExp = sht.Range("A1:K10")
    rgExp.CopyPicture Appearance:=xlScreen, Format:=xlPicture


    With sht.ChartObjects.Add(Left:=10, Top:=10, _
                        Width:=rgExp.Width, Height:=rgExp.Height)
        With .Chart
            .Paste
            .Export ThisWorkbook.Path & "\Priority Top 16.jpg"
        End With
        .Delete

    End With

End Sub

我确实为副本使用了不同的
格式
参数-不知道这是否是关键。
Private Sub CreateList()

On Error Resume Next
Range("Title") = "Priority List Last Updated: " & Now()
Dim rgExp As Range: Set rgExp = Range("A1:K10")
rgExp.CopyPicture Appearance:=xlScreen, Format:=xlBitmap

With ActiveSheet
    .ChartObjects.Add(Left:=rgExp.Left, Top:=rgExp.Top, _
    Width:=rgExp.Width, Height:=rgExp.Height)
    .Name = "Chart1"
    .Activate
    With ActiveChart
        .Paste
        .Export ThisWorkbook.Path & "\Priority Top 16.jpg"
        .Delete
    End With
End With

End Sub
Private Sub CreateList()

Application.ScreenUpdating = True

On Error Resume Next
Range("Title") = "Priority List Last Updated: " & Now()
Dim rgExp As Range: Set rgExp = ThisWorkbook.Worksheets("Sheet2").Range("A1:K10")
rgExp.CopyPicture Appearance:=xlScreen, Format:=xlBitmap

With ActiveSheet.ChartObjects.Add(Left:=rgExp.Left, Top:=rgExp.Top, _
    Width:=rgExp.Width, Height:=rgExp.Height)
    .Name = "Chart1"
    .Activate
End With

ActiveChart.Paste
ActiveSheet.ChartObjects("Chart1").Chart.Export ThisWorkbook.Path & "\Priority Top 16.jpg"
ActiveSheet.ChartObjects("Chart1").Delete
Application.ScreenUpdating = False

End Sub
Private Sub CreateList()

Dim sht As Worksheet
Dim rgExp As Range

    Application.ScreenUpdating = False

    Set sht = Sheet1

    Set rgExp = sht.Range("A1:K10")
    rgExp.CopyPicture Appearance:=xlScreen, Format:=xlPicture


    With sht.ChartObjects.Add(Left:=10, Top:=10, _
                        Width:=rgExp.Width, Height:=rgExp.Height)
        With .Chart
            .Paste
            .Export ThisWorkbook.Path & "\Priority Top 16.jpg"
        End With
        .Delete

    End With

End Sub