我使用下面的鏈接,可將Excel中的截圖並保存爲.gif文件保存GIF截圖:得到錯誤嘗試通過Excel的VBA宏
http://dmcritchie.mvps.org/excel/xl2gif.htm
當我嘗試運行宏,它給以下爲「containerbok.Activate」錯誤:
運行時錯誤「424」:所需的對象
可我知道爲什麼我收到這個錯誤?
我使用Excel 2010
謝謝!
我使用下面的鏈接,可將Excel中的截圖並保存爲.gif文件保存GIF截圖:得到錯誤嘗試通過Excel的VBA宏
http://dmcritchie.mvps.org/excel/xl2gif.htm
當我嘗試運行宏,它給以下爲「containerbok.Activate」錯誤:
運行時錯誤「424」:所需的對象
可我知道爲什麼我收到這個錯誤?
我使用Excel 2010
謝謝!
事情實際上比您發佈的鏈接中的代碼簡單一些。只需選擇想要成像的單元格範圍,然後運行以下代碼。
Sub ExportSelection()
If TypeName(Selection) = "Range" Then
'Copy the area that you have selected as a picture.
Selection.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
'Create a default bar(column) chart using the selected cells.
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlColumnClustered
'Remove all the data from the chart, leaving a blank chart.
Dim i As Integer
For i = ActiveChart.SeriesCollection.Count To 1 Step -1
ActiveChart.SeriesCollection(i).Delete
Next
'Paste the image of the selected cells onto the chart.
ActiveChart.Paste
'Export the chart as a gif image.
ActiveChart.Export Environ("USERPROFILE") & "\Desktop\chart.gif"
'Delete the existing chart.
ActiveChart.Parent.Delete
End If
End Sub
的關鍵部分是ActiveChart.Export
這在Excel 2010中進行了測試和完美的作品。
完全適合我(Excel 2003)。 –
你可以試試Excel 2010嗎? – meetpd
我想...但只有2003年可用:-( –