如何将图表导出为具有最高分辨率的图片

时间:2018-03-05 09:10:32

标签: excel vba image charts export

我编写了以下代码来选择范围并创建图表。图表稍后导出为图片。它的工作原理,然而由于选择的范围来自A2:U111,因此图像的清晰度非常差。我正在使用的代码是。

Dim sSheetName2 As String
Dim sSheetName3 As String
Dim oRangeToCopy As Range
Dim oCht As Chart
Dim comm As String
Workbooks("Workbook").Activate

Worksheets("Worksheet").Activate
sSheetName2 = "Worksheet" ' worksheet to work on



Worksheets(sSheetName2).Range("A2:U111").CopyPicture xlScreen, xlBitmap
Set oCht = Charts.Add
Charts("Chart1").Activate
ActiveWindow.Zoom = 400
With oCht
    .Paste
    .Export Filename:="D:\rr.jpg", Filtername:="JPG"
End With

我也试图减小范围大小,但它会变得像素化。

1 个答案:

答案 0 :(得分:0)

Dim sSheetName2 As String
Dim sSheetName3 As String
Dim oRangeToCopy As Range
Dim oCht As Chart
Dim comm As String
Workbooks("workbook").Activate

Worksheets("worksheet").Activate
Range("A2:U111").Select
With Selection.Font
    .Size = 9
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .TintAndShade = 0
End With
sSheetName2 = "worksheet" ' worksheet to work on
Worksheets(sSheetName2).Range("A2:U20").CopyPicture xlScreen, xlBitmap
Set oCht = Charts.Add
oCht.Activate
ActiveWindow.Zoom = 400
With oCht
    .Paste
    .Export Filename:="D:\rr.jpg", Filtername:="JPG"
End With

我多次运行代码,代码在代码中提到了如图所示。

 oCht.Activate
 ActiveWindow.Zoom = 400
 With oCht
     .Paste
     .Export Filename:="D:\rr.jpg", Filtername:="JPG"
 End With

现在它选择最近创建的图表。我也增加了字体大小。