I’m trying to use the following code in a spreadsheet that will be used across a wide range of versions of Excel :-
Sheets("Graph").ChartObjects("Chart 1").Activate
ActiveChart.ClearToMatchStyle
If I include this code as normal, it will not compile under Excel 2002, but will work fine in later versions. I don’t think the .ClearToMatchStyle command is available in Excel 2002, and this is where it’s falling down.
Is there a way I can use the code above, but only activate the commands if a version of Excel later than 2002 is found ?
Many thanks for any help,
Martin
You don’t have too many options, really.
The one you’ve got is late binding for everything that is version-dependent.
That is:
Instead of the
on error resume nextyou can:Application.Version.And in order to avoid the tedious
dim whatever as Object, you can have a function:and then: