RE: Conditional Compilation question
From: Pete Bennett (PeteBennett_at_discussions.microsoft.com)
Date: 08/25/04
- Next message: Chuck: "Re: StoryRanges collection"
- Previous message: Taylor: "How to Lock links (programatically) without incurring an update"
- In reply to: JSM: "Conditional Compilation question"
- Next in thread: JSM: "Re: Conditional Compilation question"
- Reply: JSM: "Re: Conditional Compilation question"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 25 Aug 2004 13:31:03 -0700
I'm not too sure about conditional compliation statements in Word, but here's
something that should work for you with the need for pre compliation
directives..
For the commands that are only available to later (or in some cases earlier)
builds of Word, use properties of an Object instead:-
Sub AlternativeCommands ()
Dim oApp as Object
set oApp = Application
If CInt(Application.Version) >= 10 then
oApp.SuperDooper.Command
Else
Mundane.Command
End If
Set oApp = Nothing
End Sub
Because you're using an Object type variable instead of the Application
itself, it'll compile and run fine. The downside is that it'll use more
memory and be less efficient than using the Application directly.
So, write and compile the code in the later version of Word. When you know
it works, just put the oApp in front of the extended commands (there's no
need to do this for commands that are common).
I hope that meets your needs,
Pete.
"JSM" wrote:
> 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
>
>
>
- Next message: Chuck: "Re: StoryRanges collection"
- Previous message: Taylor: "How to Lock links (programatically) without incurring an update"
- In reply to: JSM: "Conditional Compilation question"
- Next in thread: JSM: "Re: Conditional Compilation question"
- Reply: JSM: "Re: Conditional Compilation question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|