将excel文本导出为图像文件
我终于可以使用Excel VBA将excel文本导出为.jpg图像文件。 我能find文章/文章/博客如何导出图片/剪贴画作为图像,但无法find任何文字。 现在,我终于可以做到了,输出的图像模糊。 请build议如何获得良好的图像质量 。 这是导出的图片。 它看起来不错,但不是一个图片。 我试图改变格式为.png没有太大的区别。 字体使用Monotype Corsiva标题和时间新罗马斜体文本。 我的文本是在A1:L21的范围内,这里是我在互联网上find的代码,根据我的需要进行了修改
Option Explicit Sub ExportMyTextAsPicture() Dim MyChart As String, MyPicture As String Dim PicWidth As Long, PicHeight As Long Application.ScreenUpdating = False On Error GoTo Finish Range("A1:L21").Select Selection.CopyPicture Appearance:=xlScreen, Format:=xlBitmap Range("A23").Select ActiveSheet.Paste MyPicture = Selection.Name With Selection PicHeight = .ShapeRange.Height PicWidth = .ShapeRange.Width End With Charts.Add ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1" Selection.Border.LineStyle = 0 MyChart = Selection.Name & " " & Split(ActiveChart.Name, " ")(2) With ActiveSheet With .Shapes(MyChart) .Width = PicWidth .Height = PicHeight End With .Shapes(MyPicture).Copy With ActiveChart .ChartArea.Select .Paste End With .ChartObjects(1).Chart.Export Filename:="mymymy.jpg", FilterName:="jpg" .Shapes(MyChart).Cut End With ActiveSheet.DrawingObjects.Select Selection.Cut Application.ScreenUpdating = True Exit Sub Finish: MsgBox "You must select a picture" End Sub
这是原始的代码(incase任何人需要它) ,我search…导出图片/剪贴画。 (在运行macros之前需要select图像)
Option Explicit Sub ExportMyPicture() Dim MyChart As String, MyPicture As String Dim PicWidth As Long, PicHeight As Long Application.ScreenUpdating = False On Error GoTo Finish MyPicture = Selection.Name With Selection PicHeight = .ShapeRange.Height PicWidth = .ShapeRange.Width End With Charts.Add ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1" Selection.Border.LineStyle = 0 MyChart = Selection.Name & " " & Split(ActiveChart.Name, " ")(2) With ActiveSheet With .Shapes(MyChart) .Width = PicWidth .Height = PicHeight End With .Shapes(MyPicture).Copy With ActiveChart .ChartArea.Select .Paste End With .ChartObjects(1).Chart.Export Filename:="mymymy.jpg", FilterName:="jpg" .Shapes(MyChart).Cut End With Application.ScreenUpdating = True Exit Sub Finish: MsgBox "You must select a picture" End Sub
我也有类似的情况。 我在Excel中创build了需要创build到图像中的信息。 图像将始终保存为压缩图像,尤其是与字体。 它不会将字体保存为反锯齿。 为了解决这个问题,我打印/保存为PDF文件。
您也可以使用VBA以编程方式保存为PDF,如本主题和本网站所述 。