跳到主要內容

如何在Excel中將圖表導出為圖形?

在Excel中,有時,您可能會根據數據生成一些圖表,以使數據看起來更直觀,更直接。 如果出於某種目的要將圖表保存或導出到圖形中,該怎麼辦?

使用VBA代碼將圖表導出為圖形

使用Kutools for Excel將多個圖表/圖片/形狀導出為圖形 好主意3


使用VBA代碼將圖表導出為圖形

以下VBA代碼可以幫助您將活動工作表中的選定圖表導出為圖片。 並且圖片將保存在與您應用的工作簿相同的位置。 進行如下操作:

1。 選擇要導出的圖表。

2。 然後按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications 窗口。

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將多個圖表/圖片/形狀導出為圖形

Excel的Kutools 導出圖形 該實用程序可以一次在Excel中導出多個圖表,圖片或形狀。

Excel的Kutools, 與以上 300 方便的功能,使您的工作更加輕鬆。 

安裝後 Kutools for Excel,請執行以下操作:(立即免費下載Kutools for Excel!)

1。 點擊 Kutools 加 > 導入/導出 > 導出圖形,請參見屏幕截圖:

doc導出圖表7

2。 在 導出圖形 對話框中,所有 圖表, 圖片形狀 已在左側列錶框中列出,請指定要導出的類型,然後單擊 文檔按鈕1 按鈕指定保存導出圖形的目錄,同時,您可以根據需要從“導出”格式中選擇圖片的格式,例如 的GIF, JPEG, TIF or 巴布亞新幾內亞.

文檔導出圖表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選項卡為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