Conditional Compilation question

J

JSM

Hi,

Is there a way to identify the version of Word using conditional compilation
statements? I have a macro which requires a slight modification for Word
2003 using a command newly available in 2003 but the macro needs to be
compatible with earlier versions. I don't want to run two different versions
of this macro so I would prefer to use an #If statement which contains my
version checking and modifications in order to be able to compile the macro
on different versions of Word.

I know there is the VBA6 constant which helps determine whether I am using
Word 97 or other but there doesn't seem to be a way to determine whether I
am using 2000 or 2003 (for example) while still allowing me to compile.

Cheers,

John
 
P

Pete Bennett

You're welcome...

Just make sure that what code you do write using the Object method is fairly
rock solid as now any problems won't be picked up under compliation.

The other thing to watch out for is the enumerators that you might use in
your code (e.g. wdStyleTypeList). The of course will fail in earlier
versions, so instead, you should use their values and comment them so you
know what they are:-

oApp.ActiveDocument.Styles(wdStyleNormal).Type = 4 ' wdStyleTypeList

Just a thought...

Pete.
 
C

Chad DeMeyer

JSM,

Another alternative is to move the code that won't compile in earlier
versions to a separate sub or function. If the application version is 2003,
call that sub or function.

Regards,
Chad
 

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

Top