Excel 2007 Macro Problem

  • Thread starter Thread starter Robby
  • Start date Start date
R

Robby

I was just wondering if anyone knows what this message means:

"Method 'Axes' of object' _Chart failed"

The Macro works fine in Excel 2003 but crashes in Excel 2007. The line which
seems to be casuing me grief is:

ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale

Could anyone let me know what the problem could be.

Cheers
 
I was just wondering if anyone knows what this message means:

"Method 'Axes' of object' _Chart failed"

The Macro works fine in Excel 2003 but crashes in Excel 2007. The line which
seems to be casuing me grief is:

ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale

Could anyone let me know what the problem could be.

Microsoft.

They withdrew that functionality and added a different "improved" way
of doing it.
XL2007 graphs and charts are now an order of magnitude slower too.

Stick with 2003 until they get 2007 into decent working order.

Regards,
Martin Brown
 
Hi,

Can you provide more detail on the chart type and data.

The single line of code you provided worked on a column chart with date
axis.

Cheers
Andy
 
Hi Andy,

Thanks for your reply. Sorry I did couldn't get back to you earlier.

The type of graph I am working on includes a column as well as plot charts,
which calculates average values on a certain date.

Below, I have provided extra code which might help:

' This line is where the Macro Crashes
ActiveChart.Axes(xlCategory, xlSecondary).CategoryType = xlCategoryScale

ActiveChart.PlotArea.Select
With ActiveChart
.Axes(xlValue, xlSecondary).HasTitle = True
.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Duration
Days"
End With
ActiveChart.PlotArea.Select

I would appreciate what your thoughts are. From what I undertand, the line
where the Macro crashes is supposely not supported in Excel 2007, due to the
fact the VBA has been overhauled. Please correct me if I am wrong

Cheers

Robby
 
Hi,

In terms of chart type I meant is it a line or column or scatter chart.

The line of code works for me so I'm not sure it's unsupported.
If you want to email the file offline I will take a look.

Cheers
Andy
 
Hi,

In terms of chart type I meant is it a line or column or scatter chart.

The line of code works for me so I'm not sure it's unsupported.
If you want to email the file offline I will take a look.

Cheers
Andy

--












- Show quoted text -

Did you determine what the problem was? I have the exact same problem
that you described, the Axes method works fine in Excel 2003 but fails
in Excel 2007.

Thanks,
norm
 
Hi norm,

I have not received any email, so I guess the problem still exists.
Do you have an example file with the same code error that you can send?

Cheers
Andy
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
Hi,

In terms of chart type I meant is it a line or column or scatter chart.

The line of code works for me so I'm not sure it's unsupported.
If you want to email the file offline I will take a look.

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excelhttp://www.andypope.info"Robby"











- Show quoted text -

Did you determine what the problem was? I have the exact same problem
that you described, the Axes method works fine in Excel 2003 but fails
in Excel 2007.

Thanks,
norm
 
Did anyone find a solution a have the same problem?

I have the problem as well. I have a lot of VBA code using this
construct. When we "upgraded" our manufacturing people to new
machines and Office 2007 all of our certification sheets for the
equipment we sell died. So much for "Compatibility Mode" ;-).
 
Check out http://support.microsoft.com/kb/928988

The following code worked for me:

With Chart

Application.ScreenUpdating = True
.Refresh
DoEvents

.PlotArea.Width = 400
.PlotArea.Height = 290
.PlotArea.Top = 27
.PlotArea.Left = 15

Application.ScreenUpdating = False

End With

Unfortunately this seems not to work without enabling screenupdating
which in my case creates an unsightly flashing of a previously
inactive sheet AND of course slows things down further. Oddly in my
case the error only occured when .PlotArea was called for the first
time after opening the application. Thereafter everything worked as
per 2003. I imagine therefore if the user redraws the plot an
indefinite number of times in using your app that you could run the
above code once on opening and then rationalise back to the old code
for subsequent plot generations.
 
I found in Excel 2007 VBA that the following code randomly failed:
With myChtObj.Chart
Application.ScreenUpdating = True
Application.ScreenUpdating = False
.PlotArea.Height = 115
etc.....

BUT, the following fix did work (i.e. by explicitly selecting the chart):
ActiveChart.PlotArea.Select
Selection.Height = 115
 
Back
Top