How to automatically covert excel version by coding

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have some excel5 files to work on,
but some function only works in newer version.
so how do covert excel version, say use "saveas"?
any clue?thanks
 
Hi,
Say you want to sort a range but the Range.Sort method either doesn't exist
or has different parameter lists depending of the XL version. You could then
use a general Object data type instead of a Range. This will make the code
compile properly.

Dim obj as Object
Dim version as string

version=application.Version
set obj = Activesheet.Range("A1:F100") ''' range to sort

if Version= "9" then
obj.Sort ..... xl2k: with a specific list of parameters
elseif version="10" or version ="11"
obj.Sort .... xl 2002 & xl 2003: with another list of parameters
elseif version ="12"
obj.Sort ..... xl 2007... same idea
else ''' prior to xl2k
''' let's say Range.Sort doesn't exist prior to 2k then write your
own code here
''' or pop a message to the user saying it cannot be done in this
version
''' <code>
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top