VBA Copying chartareas

Johnny C

Well-known Member
Joined
Nov 7, 2006
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Greetings.

The following code isn't working.

All the literature says activate the sheet and select the chart area and copy the selection, and that works. However I don't want to select if I can avoid it. I don't see why this won't work but it doesn't.

Code:
For Each sht In ActiveWorkbook.Sheets
    For Each cht In sht.ChartObjects
           cht.ChartArea.Copy

the error is on the copy line : Error 438, Object doesn't support this property or method

TIA
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Here is a bit of code that might help.

When the code gets to the cht.type (MsgBox), the chart is in/on the Clip-Board (Paste it)

Please post results/questions

Code:
Sub DisplayChartNames()
    Dim cht
        For Each cht In Sheets("Demo").Shapes()
            Select Case cht.Type
                Case msoChart
                    MsgBox cht.Name
                    cht.Copy
                    
                    '=========================================
                    ' do what you want here to put the chart
                    'in it's place (Paste)
                    '=========================================
                    
                Case Else

            End Select
        Next
End Sub
 
Upvote 0
I think the error is because ChartArea isn't a property of the ChartObject object (cht). Try instead:

Code:
        cht.Chart.ChartArea.Copy
 
Upvote 0
Hi, I've tried that and it didn't work.

I've hunted around a far bit over this, and I've not found anywhere that doesn't use activechart.chartarea.copy so I'm wondering if it's a limitation that the chart has to be activated

I could select each sheet and turn screen updating but I'd like to solve it as its caused me problems in the past
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,536
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top