Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

Compile error in Word 2002 for .RevisionsMode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hgazdik - 30 Sep 2005 20:23 GMT
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?
Tony Jollans - 30 Sep 2005 21:40 GMT
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

> Hi,
>
[quoted text clipped - 18 lines]
>
> Any suggestions on why the 2000 compiler does like that line of code?
hgazdik - 30 Sep 2005 22:44 GMT
Thank you Tony.
That removed the compile error!

Heather
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.