Skip Compile

M

Mike Faulkner

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
 
J

Jezebel

Mike Faulkner said:
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
 
J

Jean-Guy Marcil

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
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
M

Mike Faulkner

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


Jezebel said:
Mike Faulkner said:
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
 
M

Mike Faulkner

Jean-Guy

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

Regards
Mike

Jean-Guy Marcil said:
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
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jezebel

That's VB, not VBA.



Mike Faulkner said:
yes... 'conditional compilation arguments' is one method


Jezebel said:
Mike Faulkner said:
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
 
P

Perry

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 said:
That's VB, not VBA.



Mike Faulkner said:
yes... 'conditional compilation arguments' is one method


Jezebel said:
message
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
 
M

Mike Faulkner

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 said:
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 said:
That's VB, not VBA.



Mike Faulkner said:
yes... 'conditional compilation arguments' is one method


:


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

Tony Jollans

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 said:
Jean-Guy

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

Regards
Mike

Jean-Guy Marcil said:
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
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
P

Perry

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 said:
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 said:
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 said:
That's VB, not VBA.



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


:


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

Perry

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 said:
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 said:
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 said:
That's VB, not VBA.



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


:


message
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
 

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