ChartType Error

Gofer

New Member
Joined
May 9, 2011
Messages
1
Some time ago, I wrote a macro to display a chart in a new window. It works great in Excel Version 2002 (XP), but I can't get it to work in Excel 2010. The error I am getting says:

Run-Time error '-2147467259 (80004005)'
Method 'ChartType' of object '_Chart' failed

The error occurs on the line which is: CurrentChart.ChartType = chtype

Here is my macro code:
Code:
Private Sub UpdateChart(chtype)
    YR = Worksheets("TITLE").Cells(8, 10)
    Set CurrentChart = Sheets("REPORTS").ChartObjects(1).Chart
    CurrentChart.ChartTitle.Characters.Text = YR & " ABC Membership By Class"
    CurrentChart.ChartType = chtype
'   Save chart as GIF
    fName = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
    CurrentChart.Export Filename:=fName, FilterName:="GIF"
'   Show the chart
    Image1.Picture = LoadPicture(fName)
End Sub

I'm a very novice vba user, but am in need of getting this to work in the new 2010 version. Any help would be much appreciated.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,224,614
Messages
6,179,906
Members
452,949
Latest member
beartooth91

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