View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Excel 2007 won't execute 2003 VBA code

I'm not familiar with the problems with the particular code shown. If all
else fails, you could put in a version test


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Lee" wrote in message
...
I have a macro that was created with Excel 2003 VBA code but sometimes
Excel
2007 won't execute the code and sometimes it will. Any ideas what might
be
happening? Is Excel 2007 supposed to be backwards compatible? I can't
use
the new Excel 2007 code because not all my users have Excel 2007 yet.
Most
are still using Excel 2003.

Excel 2003 Code:
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = strTitle + Chr(10) + strSubTitle
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = strXAxis
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = strYAxis
End With

However, this code does the same thing in Excel 2007 and it always works:
Excel 2007 code:
With ActiveChart
.SetElement (msoElementChartTitleAboveChart)
.ChartTitle.Text = strTitle + Chr(10) + strSubTitle
.SetElement (msoElementPrimaryCategoryAxisTitleAdjacentToAxis)
.Axes(xlCategory, xlPrimary).AxisTitle.Text = strXAxis
.SetElement (msoElementPrimaryValueAxisTitleRotated)
.Axes(xlValue, xlPrimary).AxisTitle.Text = strYAxis
End With

Thanks in advance,
Lee