跳到主要内容

如何在Excel中将图表导出为图形?

在Excel中,有时您可能会根据数据生成一些图表,以使数据看起来更直观,更直接。 如果出于某种目的要将图表保存或导出到图形中,该怎么办?

使用VBA代码将图表导出为图形

使用 Kutools for Excel 将多个图表/图片/形状导出为图形 好主意3


使用VBA代码将图表导出为图形

以下VBA代码可以帮助您将活动工作表中的选定图表导出为图片。 并且图片将保存在与您应用的工作簿相同的位置。 进行如下操作:

1。 选择要导出的图表。

2。 然后按住 ALT + F11 键,然后打开 Microsoft Visual Basic应用程序 窗口。

3。 点击 插页 > 模块,然后将以下代码粘贴到“模块窗口”中。

VBA:将图表导出为图形

Option Explicit
Sub ExportChart()
Const sSlash$ = "/"
Const sPicType$ = ".gif"
Dim sChartName$
Dim sPath$
Dim sBook$
Dim objChart As ChartObject
On Error Resume Next
Set objChart = ActiveSheet.ChartObjects(1)
If objChart Is Nothing Then
MsgBox "No charts have been detected on this sheet", 0
Exit Sub
End If
If ActiveChart Is Nothing Then
MsgBox "You must select a single chart for exporting ", 0
Exit Sub
End If
Start:
sChartName = Application.InputBox("Please Specify a name for the exported chart" & vbCr & _
"There is no default name available" & vbCr & _
"The chart will be saved in the same folder as this file", "Chart Export", "")
If sChartName = Empty Then
MsgBox "You have not entered a name for this chart", , "Invalid Entry"
Goto Start
End If
If sChartName = "False" Then
Exit Sub
End If
sBook = ActiveWorkbook.Path
sPath = sBook & sSlash & sChartName & sPicType
ActiveChart.Export Filename:=sPath, FilterName:="GIF"
End Sub

4。 然后按 F5 键运行此代码,然后在提示框中输入导出图表的名称,请参见屏幕截图:

文档导出图表1

5。 然后点击 OK,所选图表已导出到 GIF 格式,并保存在与原始文件相同的位置。 看截图:

文档导出图表2

使用上面的VBA代码,一次只能导出一个图表,如果要导出其他图表,请先选择其他图表,然后使用代码将其导出。


使用 Kutools for Excel 将多个图表/图片/形状导出为图形

Kutools for Excel 导出图形 该实用程序可以在Excel中一次导出多个图表,图片或形状。

Kutools for Excel, 与超过 300 方便的功能,使您的工作更加轻松。 

安装后 Kutools for Excel,请执行以下操作:(立即免费下载 Kutools for Excel!)

1。 点击 Kutools 加 > 导入/导出 > 导出图形,请参见屏幕截图:

doc导出图表7

2。 在 导出图形 对话框中,所有 图表, 图片形状 已在左侧列表框中列出,请指定要导出的类型,然后单击 文档按钮1 按钮以指定目录来保存导出的图形,同时,您可以根据需要从“导出”格式中选择图片的格式,例如 的GIF, JPEG格式, TIF or PNG.

文档导出图表4

3。 然后点击 OK,所有图表,图片和形状均已成功导出到指定位置。 查看屏幕截图:

文档导出图表5
;-1
文档导出图表6


请点击 导出图形 进一步了解此功能。

小费。如果您想将工作簿中的范围内容导出到独立文件,请尝试使用 Kutools for Excel 将范围导出到文件 如以下屏幕截图所示。 它在60天内无限制地提供完整功能, 请下载并立即免费试用。

将范围导出到文件

doc将单元格范围导出到文件

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (2)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi, I installed your addin and opened my excel and followed your tutorial. The export graphics button only brought up a small message box with no description. It did not bring up the Export Graphics dialog box. I have Excel 2007. If you can let me know why it is not working, really appreciate it. How to export charts to graphics in Excel? http://www.extendoffice.com/documents/excel/1151-excel-export-chart-to-image.html#a2<br /> Paul
This comment was minimized by the moderator on the site
[quote]Hi, I installed your addin and opened my excel and followed your tutorial. The export graphics button only brought up a small message box with no description. It did not bring up the Export Graphics dialog box. I have Excel 2007. If you can let me know why it is not working, really appreciate it. How to export charts to graphics in Excel? http://www.extendoffice.com/documents/excel/1151-excel-export-chart-to-image.html#a2<br /> PaulBy Paul001[/quote] Hello, Please try to uninstall the Kutools for Excel from your Control Panel first. And then go to download and install the software from http://www.extendoffice.com/download/kutools-for-excel.html<br /> If the problem persists, please try to contact me at jaychivo#extendoffice.com. Please replace # with @.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations