gpt4 book ai didi

excel - 错误修复 : Copied images in Excel 2016 VBA appear as blank images

转载 作者:行者123 更新时间:2023-12-03 02:39:42 25 4
gpt4 key购买 nike

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

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

关于excel - 错误修复 : Copied images in Excel 2016 VBA appear as blank images,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33807750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com