Trouble with revision tracking and VBA

M

Mike

Hi, I've got a document that I've been protecting (for Revision tracking
only), and I want to capture the most recent revision date from the
document. For that I've tried to create the code that follows. Everything
seems to be running okay EXCEPT that if I create a watch on myrev, or get
rid of the "on error resume next" statement, you get an "Object has been
deleted" (in the watch) "Run-time error 5852 Requested Object is Not
Available". I can use the immediate window and check that there are in fact
24 revisions currently counted in the document. If I try typing "?
thisdocument.revisions(1).date" I get the same error 5852.

How do I find the most recent revision and get it's date? What am I doing
wrong here? Any ideas?

Sub checker(doc As Document)
If myTrial.myDoc.Name = doc.Name Then
Dim myrev As Revision
Dim revdate As Date
On Error Resume Next
For Each myrev In doc.Revisions
If myrev.Date > revdate Then revdate = myrev.Date
Next myrev
On Error GoTo 0

doc.Variables("CntRevDate") = Format(revdate, "mmm dd, yyyy")
Set myrev = Nothing
End If
End Sub

--

____________________________________________________________________________
________________
Please reply to newsgroup so everyone can benefit.
Email address is not valid (see sparkingwire.com)
____________________________________________________________________________
________________
 
M

Mike

I just dug out a little snippet that might explain what's causing my
problem - the revisions are in a table. I dug out of an old ng conversation
that word treats revisions in tables weird. Is there any workaround
anyone's come up with?
 
K

Klaus Linke

Hi Mike,

Your macro does work, doesn't it?
You miss the revisions that raise the error, but I don't know a way around
that, either :-(

As far as I remember (from the thread mentioned below by Mark Tangard) the
problem seems to arise when your revision makes any change to the
end-of-cell markers (probably including formatting changes such as assigning
a paragraph style).
So one way around the problem might be to try to avoid making such revisions
in the first place.

If you wouldn't need info about the revision itself (like the date/time it
was made), but just information about where it's located, you could use the
work-around described in
http://www.google.com/[email protected]
You can cycle through the revisions using "Set myRev =
Selection.NextRevision(True)" and get some info about the Selection (such as
the page it's on) even for the broken revisions.

But this work-around doesn't help in your case.

Sorry,
Klaus
 

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