Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   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

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

  #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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Excel 2007 won't execute 2003 VBA code



"Lee" wrote in message
...
"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.



It won't, but if you put the 2007 code in a separate module the compiler
won't complain.

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?



Probably a problem as the charting engine was re-written (badly!).


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default Excel 2007 won't execute 2003 VBA code

Lee wrote:
"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.


The simplest solution is to fork the codebase and have a specifically
2007 version that is carefully bodged until it actually works in
practice. Even if you get the syntactic sugar exactly right you will
still experience intermittent race conditions where axes try to be
annotated before they have been drawn and crazy things like that without
judicious placement of delays. These timing faults are data length
dependent That is part of the reason why XL2007 charting is so glacially
slow.

I think you can sort of get away with it if there is a stub to decide
which version to run and the XL2007 code is isolated in a module that is
never run by XL2003. You may need to be careful only to use XL2003
syntax that XL2007 will tolerate so that the spreadsheet cannot be
wrecked by your user saving it in .XLSM native form.

The all new defects in XL2007 graphic model are annoying. Gratuitious
differences in the specification of objects are amongst the worst of the
incompatibilities they introduced. The new polynomial fit on graphs now
gives that same *wrong* answer as LINEST for difficult problems.

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?


XL2007 graphics object and charting are an unmitigated disaster. Avoid
and advise your customers to stick with XL2003 until XL2007 is up to
spec. No point in wasting money on a defective product. Even with SP2
applied it is better but still not really good.

My copy of Word 2007 is an even bigger crock of unstable sh*t. Somehow
it has corrupted its European paper sizes to essentially random values
that bear no relation to the true dimensions. It all works OK on US
Letter size but everything else is pretty well hopeless. What you see is
never what you get. So much for progress in Office 2007.

Regards,
Martin Brown


"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.


Very sensible of them!!!


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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 erases VBA code from Excel 2003 Andrew[_56_] Excel Programming 4 April 16th 09 12:25 PM
Should this code work in Excel 2007 as it does in 2003? Tim Miller Excel Programming 1 February 13th 09 09:52 PM
2003--2007 recognize if i'm in 2007 or 2003 via code. Miri Excel Programming 3 October 15th 08 02:50 PM
Automation C++ code works for Excel 2003, not for Excel 2007 jayo Excel Programming 0 August 6th 08 06:51 PM
Help Excel 2003 code failing in 2007 Bob C Excel Programming 12 July 25th 08 03:27 PM


All times are GMT +1. The time now is 10:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"