Hello

OS: Windows XP
App:Word XP

Can I mark a section of VBA that will not be compiled?

Why? I want to include Word 2003 Compatibility Options in a Word 2002 Tool.
[Application.Version] will determine what code is run. Ideally

if Application.Version = 11 then
Compatilitity = 2002
ElseIf Application.Version = 12
Compatilitity = 2003
etc.

Any assistance will be greatly appreciated.

Regards
Mike

Re: Skip Compile by Jezebel

Jezebel
Fri Mar 16 09:01:14 CDT 2007


"Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in message
news:148AC91C-E2C2-4DCB-879C-01746EDB83F0@microsoft.com...
> Hello
>
> OS: Windows XP
> App:Word XP
>
> Can I mark a section of VBA that will not be compiled?

no.


>
> Why? I want to include Word 2003 Compatibility Options in a Word 2002
> Tool.
> [Application.Version] will determine what code is run. Ideally
>
> if Application.Version = 11 then
> Compatilitity = 2002
> ElseIf Application.Version = 12
> Compatilitity = 2003
> etc.
>
> Any assistance will be greatly appreciated.
>
> Regards
> Mike



Re: Skip Compile by Jean-Guy

Jean-Guy
Fri Mar 16 09:37:23 CDT 2007

Mike Faulkner was telling us:
Mike Faulkner nous racontait que :

> Hello
>
> OS: Windows XP
> App:Word XP
>
> Can I mark a section of VBA that will not be compiled?
>
> Why? I want to include Word 2003 Compatibility Options in a Word 2002
> Tool. [Application.Version] will determine what code is run. Ideally
>
> if Application.Version = 11 then
> Compatilitity = 2002
> ElseIf Application.Version = 12
> Compatilitity = 2003
> etc.
>
> Any assistance will be greatly appreciated.
>
> Regards
> Mike

If I remember correctly, Word only compile the current modules, so you can
use that to your advantage.
What you can do is have a central module that will determine the current
version, something like the code you posted.

Then, once the current version has been determined, this central module will
call a sub in one of two modules - one for each version of Word that you
want to use. This way, Word will compile only the called modules - the
central/starting one and the one called from there. The initial version
detecting code could be in the Document_Open and/or Document_New subs of the
ThisDocument module.

It is not ideal as you may have to write some code twice.... What you could
do is have a fourth module that would hold the code that is not dependent on
the current Word version and have the other version-dependant module call
its subs as needed.


--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org



Re: Skip Compile by MikeFaulkner

MikeFaulkner
Fri Mar 16 11:04:08 CDT 2007

yes... 'conditional compilation arguments' is one method


"Jezebel" wrote:

>
> "Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in message
> news:148AC91C-E2C2-4DCB-879C-01746EDB83F0@microsoft.com...
> > Hello
> >
> > OS: Windows XP
> > App:Word XP
> >
> > Can I mark a section of VBA that will not be compiled?
>
> no.
>
>
> >
> > Why? I want to include Word 2003 Compatibility Options in a Word 2002
> > Tool.
> > [Application.Version] will determine what code is run. Ideally
> >
> > if Application.Version = 11 then
> > Compatilitity = 2002
> > ElseIf Application.Version = 12
> > Compatilitity = 2003
> > etc.
> >
> > Any assistance will be greatly appreciated.
> >
> > Regards
> > Mike
>
>
>

Re: Skip Compile by MikeFaulkner

MikeFaulkner
Fri Mar 16 11:05:43 CDT 2007

Jean-Guy

Many thanks for you assistance. I am testing it using 'Conditional
Compilation Arguements'.

Regards
Mike

"Jean-Guy Marcil" wrote:

> Mike Faulkner was telling us:
> Mike Faulkner nous racontait que :
>
> > Hello
> >
> > OS: Windows XP
> > App:Word XP
> >
> > Can I mark a section of VBA that will not be compiled?
> >
> > Why? I want to include Word 2003 Compatibility Options in a Word 2002
> > Tool. [Application.Version] will determine what code is run. Ideally
> >
> > if Application.Version = 11 then
> > Compatilitity = 2002
> > ElseIf Application.Version = 12
> > Compatilitity = 2003
> > etc.
> >
> > Any assistance will be greatly appreciated.
> >
> > Regards
> > Mike
>
> If I remember correctly, Word only compile the current modules, so you can
> use that to your advantage.
> What you can do is have a central module that will determine the current
> version, something like the code you posted.
>
> Then, once the current version has been determined, this central module will
> call a sub in one of two modules - one for each version of Word that you
> want to use. This way, Word will compile only the called modules - the
> central/starting one and the one called from there. The initial version
> detecting code could be in the Document_Open and/or Document_New subs of the
> ThisDocument module.
>
> It is not ideal as you may have to write some code twice.... What you could
> do is have a fourth module that would hold the code that is not dependent on
> the current Word version and have the other version-dependant module call
> its subs as needed.
>
>
> --
>
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE@CAPSsympatico.caTHISTOO
> Word MVP site: http://www.word.mvps.org
>
>
>

Re: Skip Compile by Jezebel

Jezebel
Fri Mar 16 12:54:34 CDT 2007

That's VB, not VBA.



"Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in message
news:D39DB0F2-7361-45BE-8596-BD1CFF134F44@microsoft.com...
> yes... 'conditional compilation arguments' is one method
>
>
> "Jezebel" wrote:
>
>>
>> "Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in message
>> news:148AC91C-E2C2-4DCB-879C-01746EDB83F0@microsoft.com...
>> > Hello
>> >
>> > OS: Windows XP
>> > App:Word XP
>> >
>> > Can I mark a section of VBA that will not be compiled?
>>
>> no.
>>
>>
>> >
>> > Why? I want to include Word 2003 Compatibility Options in a Word 2002
>> > Tool.
>> > [Application.Version] will determine what code is run. Ideally
>> >
>> > if Application.Version = 11 then
>> > Compatilitity = 2002
>> > ElseIf Application.Version = 12
>> > Compatilitity = 2003
>> > etc.
>> >
>> > Any assistance will be greatly appreciated.
>> >
>> > Regards
>> > Mike
>>
>>
>>



Re: Skip Compile by Perry

Perry
Sat Mar 17 03:47:47 CDT 2007

> That's VB, not VBA.

??

Below sequence is straight from plain Word VBA
In other words, toggle the constant "bCompile" to include/exculde code
execution
and hash the code parts within an It .. Then test evaluating the bCompile
constant.

#Const bComplile = False

Sub testing()
#If bComplile Then
MsgBox "Perry"
rem And the rest of your code goes here
rem to be included/excluded from compilation
#End If
End Sub

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



"Jezebel" <warcrimes@whitehouse.gov> schreef in bericht
news:efg8pQ$ZHHA.2316@TK2MSFTNGP04.phx.gbl...
> That's VB, not VBA.
>
>
>
> "Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in message
> news:D39DB0F2-7361-45BE-8596-BD1CFF134F44@microsoft.com...
>> yes... 'conditional compilation arguments' is one method
>>
>>
>> "Jezebel" wrote:
>>
>>>
>>> "Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in
>>> message
>>> news:148AC91C-E2C2-4DCB-879C-01746EDB83F0@microsoft.com...
>>> > Hello
>>> >
>>> > OS: Windows XP
>>> > App:Word XP
>>> >
>>> > Can I mark a section of VBA that will not be compiled?
>>>
>>> no.
>>>
>>>
>>> >
>>> > Why? I want to include Word 2003 Compatibility Options in a Word 2002
>>> > Tool.
>>> > [Application.Version] will determine what code is run. Ideally
>>> >
>>> > if Application.Version = 11 then
>>> > Compatilitity = 2002
>>> > ElseIf Application.Version = 12
>>> > Compatilitity = 2003
>>> > etc.
>>> >
>>> > Any assistance will be greatly appreciated.
>>> >
>>> > Regards
>>> > Mike
>>>
>>>
>>>
>
>


Re: Skip Compile by MikeFaulkner

MikeFaulkner
Mon Mar 19 08:47:05 CDT 2007

Perry

Many thanks. I am having trouble programatically toggling the constant
'#Const bComplile = False'.

Shouldn't the following suffice?
If application.version = 11 then
#Const bComplile = False
ElseIf application.version = 12 then
#Const bComplile = True
End If

Regards
Mike

"Perry" wrote:

> > That's VB, not VBA.
>
> ??
>
> Below sequence is straight from plain Word VBA
> In other words, toggle the constant "bCompile" to include/exculde code
> execution
> and hash the code parts within an It .. Then test evaluating the bCompile
> constant.
>
> #Const bComplile = False
>
> Sub testing()
> #If bComplile Then
> MsgBox "Perry"
> rem And the rest of your code goes here
> rem to be included/excluded from compilation
> #End If
> End Sub
>
> --
> Krgrds,
> Perry
>
> System:
> Vista/Office Ultimate
> VS2005/VSTO2005 SE
>
>
>
> "Jezebel" <warcrimes@whitehouse.gov> schreef in bericht
> news:efg8pQ$ZHHA.2316@TK2MSFTNGP04.phx.gbl...
> > That's VB, not VBA.
> >
> >
> >
> > "Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in message
> > news:D39DB0F2-7361-45BE-8596-BD1CFF134F44@microsoft.com...
> >> yes... 'conditional compilation arguments' is one method
> >>
> >>
> >> "Jezebel" wrote:
> >>
> >>>
> >>> "Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in
> >>> message
> >>> news:148AC91C-E2C2-4DCB-879C-01746EDB83F0@microsoft.com...
> >>> > Hello
> >>> >
> >>> > OS: Windows XP
> >>> > App:Word XP
> >>> >
> >>> > Can I mark a section of VBA that will not be compiled?
> >>>
> >>> no.
> >>>
> >>>
> >>> >
> >>> > Why? I want to include Word 2003 Compatibility Options in a Word 2002
> >>> > Tool.
> >>> > [Application.Version] will determine what code is run. Ideally
> >>> >
> >>> > if Application.Version = 11 then
> >>> > Compatilitity = 2002
> >>> > ElseIf Application.Version = 12
> >>> > Compatilitity = 2003
> >>> > etc.
> >>> >
> >>> > Any assistance will be greatly appreciated.
> >>> >
> >>> > Regards
> >>> > Mike
> >>>
> >>>
> >>>
> >
> >
>
>

Re: Skip Compile by Tony

Tony
Mon Mar 19 09:01:08 CDT 2007

There is no conditional compiler constants for any Word version so, although
you can have conditionally compiled code you can not have Word version as
(part of) the condition.

Depending on exactly what it is you want to code you may be able to use
CallByName to include Word 2003 properties and methods in Word 2002 code -
because they are passed to CallByName as strings and, effectively, compiled
on demand subject to a condition (Application.Version) which will compile in
all versions.

--
Enjoy,
Tony

"Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> schreef in bericht
news:663181D0-8B8D-44EF-84C1-C3CE4A4E9E21@microsoft.com...
> Jean-Guy
>
> Many thanks for you assistance. I am testing it using 'Conditional
> Compilation Arguements'.
>
> Regards
> Mike
>
> "Jean-Guy Marcil" wrote:
>
>> Mike Faulkner was telling us:
>> Mike Faulkner nous racontait que :
>>
>> > Hello
>> >
>> > OS: Windows XP
>> > App:Word XP
>> >
>> > Can I mark a section of VBA that will not be compiled?
>> >
>> > Why? I want to include Word 2003 Compatibility Options in a Word 2002
>> > Tool. [Application.Version] will determine what code is run. Ideally
>> >
>> > if Application.Version = 11 then
>> > Compatilitity = 2002
>> > ElseIf Application.Version = 12
>> > Compatilitity = 2003
>> > etc.
>> >
>> > Any assistance will be greatly appreciated.
>> >
>> > Regards
>> > Mike
>>
>> If I remember correctly, Word only compile the current modules, so you
>> can
>> use that to your advantage.
>> What you can do is have a central module that will determine the current
>> version, something like the code you posted.
>>
>> Then, once the current version has been determined, this central module
>> will
>> call a sub in one of two modules - one for each version of Word that you
>> want to use. This way, Word will compile only the called modules - the
>> central/starting one and the one called from there. The initial version
>> detecting code could be in the Document_Open and/or Document_New subs of
>> the
>> ThisDocument module.
>>
>> It is not ideal as you may have to write some code twice.... What you
>> could
>> do is have a fourth module that would hold the code that is not dependent
>> on
>> the current Word version and have the other version-dependant module call
>> its subs as needed.
>>
>>
>> --
>>
>> Salut!
>> _______________________________________
>> Jean-Guy Marcil - Word MVP
>> jmarcilREMOVE@CAPSsympatico.caTHISTOO
>> Word MVP site: http://www.word.mvps.org
>>
>>
>>


Re: Skip Compile by Perry

Perry
Mon Mar 19 20:49:01 CDT 2007

> If application.version = 11 then
> #Const bComplile = False
> ElseIf application.version = 12 then
> #Const bComplile = True

No can't do that.

You can't change Conditional arguments (or #Const) on the fly.
They have to be set during designtime.

You can either use a (conditional) #Const OR
set conditional arguments to yr VBA project.
There's an inputbox in the properties screen of yr VBA project in which
you can set them.

In VB you can also use commandline command to set the conditional arguments
to yr VB project but I haven't
done this in VBA (yet)
But again, these settings have to be set during designtime as well.

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



"Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> schreef in bericht
news:8548A882-2F6B-49A2-91CF-CB952DF0321F@microsoft.com...
> Perry
>
> Many thanks. I am having trouble programatically toggling the constant
> '#Const bComplile = False'.
>
> Shouldn't the following suffice?
> If application.version = 11 then
> #Const bComplile = False
> ElseIf application.version = 12 then
> #Const bComplile = True
> End If
>
> Regards
> Mike
>
> "Perry" wrote:
>
>> > That's VB, not VBA.
>>
>> ??
>>
>> Below sequence is straight from plain Word VBA
>> In other words, toggle the constant "bCompile" to include/exculde code
>> execution
>> and hash the code parts within an It .. Then test evaluating the bCompile
>> constant.
>>
>> #Const bComplile = False
>>
>> Sub testing()
>> #If bComplile Then
>> MsgBox "Perry"
>> rem And the rest of your code goes here
>> rem to be included/excluded from compilation
>> #End If
>> End Sub
>>
>> --
>> Krgrds,
>> Perry
>>
>> System:
>> Vista/Office Ultimate
>> VS2005/VSTO2005 SE
>>
>>
>>
>> "Jezebel" <warcrimes@whitehouse.gov> schreef in bericht
>> news:efg8pQ$ZHHA.2316@TK2MSFTNGP04.phx.gbl...
>> > That's VB, not VBA.
>> >
>> >
>> >
>> > "Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in
>> > message
>> > news:D39DB0F2-7361-45BE-8596-BD1CFF134F44@microsoft.com...
>> >> yes... 'conditional compilation arguments' is one method
>> >>
>> >>
>> >> "Jezebel" wrote:
>> >>
>> >>>
>> >>> "Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in
>> >>> message
>> >>> news:148AC91C-E2C2-4DCB-879C-01746EDB83F0@microsoft.com...
>> >>> > Hello
>> >>> >
>> >>> > OS: Windows XP
>> >>> > App:Word XP
>> >>> >
>> >>> > Can I mark a section of VBA that will not be compiled?
>> >>>
>> >>> no.
>> >>>
>> >>>
>> >>> >
>> >>> > Why? I want to include Word 2003 Compatibility Options in a Word
>> >>> > 2002
>> >>> > Tool.
>> >>> > [Application.Version] will determine what code is run. Ideally
>> >>> >
>> >>> > if Application.Version = 11 then
>> >>> > Compatilitity = 2002
>> >>> > ElseIf Application.Version = 12
>> >>> > Compatilitity = 2003
>> >>> > etc.
>> >>> >
>> >>> > Any assistance will be greatly appreciated.
>> >>> >
>> >>> > Regards
>> >>> > Mike
>> >>>
>> >>>
>> >>>
>> >
>> >
>>
>>


Re: Skip Compile by Perry

Perry
Mon Mar 19 20:48:19 CDT 2007

> If application.version = 11 then
> #Const bComplile = False
> ElseIf application.version = 12 then
> #Const bComplile = True

No can't do that.

You can't change Conditional arguments (or #Const) on the fly.
They have to be set during designtime.

You can either use a (conditional) #Const OR
set conditional arguments to yr VBA project.
There's an inputbox in the properties screen of yr VBA project in which
you can set them.

In VB you can also use commandline command to set the conditional arguments
to yr VB project but I haven't
done this in VBA (yet)
But again, these settings have to be set during designtime as well.

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



"Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> schreef in bericht
news:8548A882-2F6B-49A2-91CF-CB952DF0321F@microsoft.com...
> Perry
>
> Many thanks. I am having trouble programatically toggling the constant
> '#Const bComplile = False'.
>
> Shouldn't the following suffice?
> If application.version = 11 then
> #Const bComplile = False
> ElseIf application.version = 12 then
> #Const bComplile = True
> End If
>
> Regards
> Mike
>
> "Perry" wrote:
>
>> > That's VB, not VBA.
>>
>> ??
>>
>> Below sequence is straight from plain Word VBA
>> In other words, toggle the constant "bCompile" to include/exculde code
>> execution
>> and hash the code parts within an It .. Then test evaluating the bCompile
>> constant.
>>
>> #Const bComplile = False
>>
>> Sub testing()
>> #If bComplile Then
>> MsgBox "Perry"
>> rem And the rest of your code goes here
>> rem to be included/excluded from compilation
>> #End If
>> End Sub
>>
>> --
>> Krgrds,
>> Perry
>>
>> System:
>> Vista/Office Ultimate
>> VS2005/VSTO2005 SE
>>
>>
>>
>> "Jezebel" <warcrimes@whitehouse.gov> schreef in bericht
>> news:efg8pQ$ZHHA.2316@TK2MSFTNGP04.phx.gbl...
>> > That's VB, not VBA.
>> >
>> >
>> >
>> > "Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in
>> > message
>> > news:D39DB0F2-7361-45BE-8596-BD1CFF134F44@microsoft.com...
>> >> yes... 'conditional compilation arguments' is one method
>> >>
>> >>
>> >> "Jezebel" wrote:
>> >>
>> >>>
>> >>> "Mike Faulkner" <MikeFaulkner@discussions.microsoft.com> wrote in
>> >>> message
>> >>> news:148AC91C-E2C2-4DCB-879C-01746EDB83F0@microsoft.com...
>> >>> > Hello
>> >>> >
>> >>> > OS: Windows XP
>> >>> > App:Word XP
>> >>> >
>> >>> > Can I mark a section of VBA that will not be compiled?
>> >>>
>> >>> no.
>> >>>
>> >>>
>> >>> >
>> >>> > Why? I want to include Word 2003 Compatibility Options in a Word
>> >>> > 2002
>> >>> > Tool.
>> >>> > [Application.Version] will determine what code is run. Ideally
>> >>> >
>> >>> > if Application.Version = 11 then
>> >>> > Compatilitity = 2002
>> >>> > ElseIf Application.Version = 12
>> >>> > Compatilitity = 2003
>> >>> > etc.
>> >>> >
>> >>> > Any assistance will be greatly appreciated.
>> >>> >
>> >>> > Regards
>> >>> > Mike
>> >>>
>> >>>
>> >>>
>> >
>> >
>>
>>