View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
lee lee is offline
external usenet poster
 
Posts: 184
Default Excel 2007 won't execute 2003 VBA code

"Application.Version" will give me the version number but I can't use that to
direct the software to the appropriate 2003 or 2007 code because the newer
2007 code won't compile in Excel 2003. Also "conditional compilation" is
pretty much useless because I can't expect the user to go into the VBE and
set conditional constants.

What I really need is for Excel 2007 to be backward compatible with 2003 VBA
code or else I'll have to write two programs, one for Excel 2003 users and
one for Excel 2007 users. Does anyone know if it is backward compatible?

"Don Guillett" wrote:

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