以下のリンクを使用して、Excel のスクリーンショットを撮り、.gif ファイルとして保存しています。
http://dmcritchie.mvps.org/excel/xl2gif.htm
マクロを実行しようとすると、「containerbok.Activate」で次のエラーが発生します。
実行時エラー '424': オブジェクトが必要です
このエラーが発生する理由を教えてください。
エクセル2010を使用しています
ありがとう!
以下のリンクを使用して、Excel のスクリーンショットを撮り、.gif ファイルとして保存しています。
http://dmcritchie.mvps.org/excel/xl2gif.htm
マクロを実行しようとすると、「containerbok.Activate」で次のエラーが発生します。
実行時エラー '424': オブジェクトが必要です
このエラーが発生する理由を教えてください。
エクセル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 でテストされており、完全に機能します。