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

问题描述 投票:0回答:1

我编写了以下代码来选择范围并创建图表。图表稍后导出为图片。它的工作原理,然而由于选择的范围来自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

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

excel vba image charts export
1个回答
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

我多次运行代码,代码放大了代码中提到的chart1。

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

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

© www.soinside.com 2019 - 2024. All rights reserved.