Name

workbook.ActiveChart

Synopsis

Returns a reference to the Chart object that currently has focus in Excel. If some other type of object has focus, returns Nothing. The following code captures a bitmap of the active chart and pastes the image into Microsoft Paint:

If Not (ActiveChart Is Nothing) Then
    ActiveChart.CopyPicture xlScreen, xlBitmap, xlScreen
    Shell "mspaint.exe", vbNormalFocus
    DoEvents
    AppActivate "Untitled - Paint", True
    SendKeys "^v", True
End If

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.