November 29th, 2005

How Can I Set Word’s Revision View Mode to Final?

Hey, Scripting Guy! Question

Hey, Scripting Guy! In Microsoft Word 2003, my documents open as Final Showing Markup. How can I change this so the default view is Final?

— CD

SpacerHey, Scripting Guy! AnswerScript Center

Hey, CD. You know, this is the first Hey, Scripting Guy! column we’ve written since returning from the Thanksgiving holiday. After four days of eating, football, eating, basketball, and then a little more eating (well, OK, a lot more eating), we thought it would be smart to pick a really easy question to answer, something to help us get back into the swing of things. And that would have been smart had we actually picked an easy question. Instead, we chose your question.

As we quickly discovered, this was a bit trickier than we had expected (and had hoped). For one thing, we couldn’t find a way to make Final the global default; that is, to configure Word so that all documents would then open up with the revision view mode set to Final. Instead, it appears that the revision view must be configured on a per-document basis. Therefore, what we’ve given you is a script that opens a specific document and then sets the revision view mode for that document. That’s not quite what you were looking for, but it was the best we could do.

For another, it turns out that the RevisionsView property in Word has only two settings: Final Showing Markup and Original Showing Markup. That’s fine, except that Word itself has four such settings: Final Showing Markup, Original Showing Markup, Original, and – the one you wanted – Final. Did that throw us for a loop? Do you even have to ask?

Fortunately, the Scripting Guys have been thrown for so many loops that things like that don’t bother us anymore. It took a little experimenting and a little poking around the Microsoft Word object model, but eventually we came up with a solution. For example, here’s a script that opens the document C:\Scripts\Test.doc and sets the revision view mode to Final:

Const wdRevisionsViewFinal = 0

Set objWord = CreateObject(“Word.Application”) Set objDoc = objWord.Documents.Open(“c:\scripts\test.doc”)

Set objView = objWord.ActiveDocument.ActiveWindow.View

objView.RevisionsView = wdRevisionsViewFinal objView.ShowRevisionsAndComments = False

objWord.Visible = True

As you can see, the script isn’t very long and it isn’t very complex; it’s just a little tricky. We start out by defining a constant named wdRevisionsViewFinal and setting the value to 0; needless to say, we’ll use this constant to indicate whether the RevisionsView property should be set to Final or Final Showing Markup. (Don’t worry, we’ll explain how to get one or the other.) What if we wanted to set the RevisionsView to Original or Original Showing Markup? In that case, we’d need to define a constant named wdRevisionsViewOriginal and set the value to 1:

Const wdRevisionsViewOriginal = 1

Next we create an instance of the Word.Application object and then use the Open method to open the file C:\Scripts\Test.doc. We then use this line of code to create an object reference to the View object for this document:

Set objView = objWord.ActiveDocument.ActiveWindow.View

Now we need to do two things. First, we set the value of the RevisionsView property to 0 (using the constant wdRevisionsViewFinal). Setting RevisionsView to 0 gives us a revisions view mode of Final Showing Markup; setting the RevisionsView to 1 gives us a view mode of Original Showing Markup.

“But wait,” you say, “we don’t want Final Showing Markup; we want just plain old Final.” Understood. In order to get to that mode you first have to configure the RevisionsView property; at that point, you then need to set the ShowRevisionsAndComments property to False:

objView.ShowRevisionsAndComments = False

That should do the trick. After configuring both RevisionsView and ShowRevisionsAndComments we then set the Visible property to True: that makes Test.doc visible, and shows us that the revisions view mode has been set to Final.

Confused? Don’t feel bad; we were confused at first, too. But maybe this little table, which shows the required settings for each view mode, will help:

View Mode

RevisionsView

ShowRevisionsAndComments

Final

0

False

FinalShowingMarkup

0

True

Original

1

False

OriginalShowingMarkup

1

True

Play around with it a bit, and you’ll catch on in no time.

Note. Next Thanksgiving we’re definitely going to pick a question that’s a little easier to answer. In fact, for those of you who like to get a jump on the holidays here’s the column for Thanksgiving 2006:

Hey, Scripting Guy! How can I make a message box appear using WSH?

— GS

Hey, GS. Here’s how:

Wscript.Echo “This is my message box.”

If only we’d picked that question this year ….

Author

0 comments

Discussion are closed.