RE: Conditional Compilation question

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Pete Bennett (PeteBennett_at_discussions.microsoft.com)
Date: 08/25/04


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



Relevant Pages

  • Re: Conditional Compilation question
    ... John ... > set oApp = Application ... write and compile the code in the later version of Word. ...
    (microsoft.public.word.vba.general)
  • [PATCHSET 0-5] remove unneeded nfsd #includes
    ... Some arch files had unneeded #includes directives from linux/nfsd/*. ... In an effort to move some of the now public nfsd headers to the source ... please compile with this patch? ...
    (Linux-Kernel)
  • Re: Resource compiler error with Pocket PC 2003
    ... I think the real problem is not quite where you're looking. ... through that header file for precompiler directives that depend on ... whether Pocket PC is the target. ... > I can't compile my project because of this issue. ...
    (microsoft.public.pocketpc.developer)
  • Re: Could not load file or assembly *
    ... you probably did not include page directives for references to other pages ... pages are compiled into seperate dlls, ... are batched into a single dll (for compile performance), ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: multiple C++ compiled to one object
    ... It is the preprocessor that replaces #include directives with file contents, ... A machine slow enough to notice the time it takes to compile each source ... Source files whose contents don't add much time to the per-file overhead. ... Precompiled headers are not available. ...
    (microsoft.public.vc.language)