我有以下代码将范围转换为图像并将其保存到文件。我的问题是,我想将复制的范围扩大到更高的分辨率/ dpi以获得更大的图像
Sub SaveRangeToImage(rng As Range, path As String)
''' Set Range you want to export to file
Dim rgExp As Range: Set rgExp = rng
''' Copy range as picture onto Clipboard
rgExp.CopyPicture Appearance:=xlScreen, Format:=xlPicture
''' Create an empty chart with exact size of range copied
With ActiveSheet.ChartObjects.Add(Left:=rgExp.Left, Top:=rgExp.Top, _
Width:=rgExp.Width, Height:=rgExp.Height)
.name = "img_img"
.Activate
End With
''' Paste into chart area, export to file, delete chart.
ActiveChart.Paste
ActiveSheet.ChartObjects("img_img").Chart.Export path
ActiveSheet.ChartObjects("img_img").Delete
End Sub
我需要缩放图像以获得最佳文本质量,如果我之后调整大小,它会让我的文本可见性很差。
有没有人对这个问题有所了解?
答案 0 :(得分:2)
尝试更改参数:
rgExp.CopyPicture Appearance:=xlPrinter, Format:=xlBitmap
但是@ Dubison的建议将会产生重大影响:
答案 1 :(得分:0)
增加活动窗口的缩放以提高分辨率。
导出前添加:ActiveWindow.Zoom = 300 然后在导出后添加:ActiveWindow.Zoom = 100