彰化一整天的論壇

 找回密碼
 立即註冊
查看: 606|回復: 0

【轉貼】將excel部分範圍儲存成圖片

[複製鏈接]
發表於 2018-3-21 08:48:46 | 顯示全部樓層 |閱讀模式

VBA - Range to jpg picture
  1. Sub Export()

  2. Dim oWs As Worksheet
  3. Dim oRng As Range
  4. Dim oChrtO As ChartObject
  5. Dim lWidth As Long, lHeight As Long

  6. Set oWs = ActiveSheet
  7. Set oRng = oWs.Range("B2:H11")

  8. oRng.CopyPicture xlScreen, xlPicture
  9. lWidth = oRng.Width
  10. lHeight = oRng.Height

  11. Set oChrtO = oWs.ChartObjects.Add(Left:=0, Top:=0, Width:=lWidth, Height:=lHeight)

  12. oChrtO.Activate
  13. With oChrtO.Chart
  14.   .Paste
  15.   .Export Filename:="Case.jpg", Filtername:="JPG"
  16. End With

  17. oChrtO.Delete

  18. End Sub
複製代碼
資料來源: https://stackoverflow.com/questi ... ange-to-jpg-picture
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

 ㄚ母滴雞湯
 員林香純滴雞精

Archiver|手機版|小黑屋|彰化一整天的論壇(Excel,Office)  |网站地图

GMT+8, 2019-8-19 09:24 , Processed in 0.117821 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表