Compile error in Word 2002 for .RevisionsMode

H

hgazdik

Hi,

I need this line of code for use in Word 2002 and greater:
With ActiveWindow.View.RevisionsMode = wdInLineRevisions

But for use in Word 2000 (version 9) I need this line of code to be
skipped.
The compiler throws and error when run on a Word 2000 machine, even
when it is being told to skip the line.
================================================
strVersion = Application.Version
strVersion = Left(strVersion, 1)
If strVersion = 9 then GoTo Version9Skip2
With ActiveWindow.View.RevisionsMode = wdInLineRevisions

Version9Skip2:
With ActiveDocument
.trackRevisions = True
.ShowRevisions = False
End With

Any suggestions on why the 2000 compiler does like that line of code?
 
T

Tony Jollans

There are two problems here, both caused by the fact that you have to be
able to compile the code in both versions - there is no compiler variable
which distinguishes the word version.

1) the Word 2000 compiler doesn't like RevisionsMode as a property

To get the property name past the compiler you have to disguise it; you can
do this by passing it as a string to the VBA CallByName method. Word 2000
will then compile OK, but just not run the statement because the version
condition will fail.

2) the Word 2000 compiler won't recognise the constant, wdInLineRevisions

If you have Option Explicit, you will not be able to use the Word constant
because the compiler will reject it as an undeclared variable. You can
either declare the constant yourself and the Word 2002 compiler will use
your version instead of Word's, or you can just use the constant 1 instead.
Or you could not use Option Explicit but I wouldn't recommend that.

Putting it all together (and ignoring the "With" you posted) you get

Const wdInLineRevisions = 1
If Application.Version >= 10 Then
CallByName ActiveWindow.View, "RevisionsMode", VbLet, wdInLineRevisions
End If

Enjoy,
Tony
 

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