Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Revisions collection stops code in a table

97 views
Skip to first unread message

Mark Tangard

unread,
Apr 23, 2002, 10:48:35 PM4/23/02
to

The code below is thoroughly simplified from the macro I'm trying to build but
demonstrates the same problem -- it runs fine until a revision is found within
a table. Questions: (1) Why? (2) Why does it stop even if I insert something
like If rv.Range.Information(wdWithinTable) Then skedaddle...? The error says
the requested object (the revision) is not available. I'd be OK telling it to
skip revisions that happen to be in tables but can't even seem to do that much.
Is there a way around this?

Sub ListRevPages()
Dim rv As Revision
For Each rv In ActiveDocument.Range.Revisions
MsgBox rv.Range.Information(wdActiveEndPageNumber) '<---stops here.
Next rv
End Sub

TIA

Mark Tangard <mtan...@speakeasy.net>, Microsoft Word MVP
"Life is nothing if you're not obsessed." --John Waters

ibby

unread,
Apr 24, 2002, 1:40:29 AM4/24/02
to
Hi Mark,

I can't reproduce your problem - WordXP SP1. I don't get the error with
revisions in a Table. Do you want to send over a test document ?

---
ibby


"Mark Tangard" <mtan...@speakeasy.net> wrote in message
news:3CC61D03...@speakeasy.net...

Jay Freedman

unread,
Apr 24, 2002, 12:22:04 PM4/24/02
to
Hi, Mark and ibby,

I *do* get the error in Word 2000 SR-1. If I bring up rv in a watch window when the error occurs, it
says "<Object has been deleted.>"

This is just an ordinary 4-page document to which I added a small table on page 3, and one revision
on each page. If the revision on page 3 is outside the table, no problem; but make a revision in the
table, and the macro falls over.

--
Regards,
Jay Freedman
Microsoft Word MVP Word MVP FAQ site: http://www.mvps.org/word

"ibby" <ib...@bigpond.net.au> wrote in message news:eUHegJ16BHA.584@tkmsftngp03...

Mark Baird

unread,
Apr 24, 2002, 3:39:53 PM4/24/02
to
This is a problem found in Word 2000 which has been
corrected in Word XP, although as is always the case
Microsoft introduced several new bugs in XP.

The only way that I found to get around this is to use the
selection object.

Mark Baird

>.
>

Mark Tangard

unread,
Apr 25, 2002, 4:59:57 AM4/25/02
to
Hi Mark,

Could you elaborate on how you'd use the Selection object to
work around this? I don't see how.

(This is indeed Word 2000 SR-1. Thanks to Jay for proving
I'm not going mad....)

--
Mark Tangard <mtan...@speakeasy.net>


"Life is nothing if you're not obsessed." --John Waters

Klaus Linke

unread,
Apr 25, 2002, 7:51:59 PM4/25/02
to
Hi Mark,

I think the other Mark means something like

Sub ListRevPages()
Dim rv As Revision

Dim posOld As Long, posNew As Long
Selection.HomeKey (wdStory)
Set rv = Selection.NextRevision(True)
Do Until posNew < posOld
MsgBox Selection.Information(wdActiveEndPageNumber)
Selection.Collapse (wdCollapseEnd)
Set rv = Selection.NextRevision(True)
posOld = posNew
posNew = Selection.start
Loop
End Sub

Regards, Klaus

Sesha Reddigari

unread,
Apr 27, 2002, 8:54:19 AM4/27/02
to
Mark,
It is a strange coincidence - I have been struggling with the same problem the last
couple of days!
I don't have a solution to the main problem, but I was able to get around the other
issue of skipping the table.

When the revision inside a table is picked by my code (selection.nextrevision), the
whole row is selected. That's when VBA seems to falter. It doesn's seem to be able
to handle the whole row, with all the cells, cell text, and the chr(7) character
in each of those cells.....

I was able to skip the table with the following:

If selection.information (wdwithintable) then
selection.expand wdtable
selection.collapse wdcollapseend

and then start your loop of finding revisions again.

Sesha Reddigari


Mark Tangard <mtan...@speakeasy.net> wrote in message news:<3CC61D03...@speakeasy.net>...

Mark Tangard

unread,
Apr 27, 2002, 6:04:28 PM4/27/02
to

Thanks, Klaus, this works great (although it took a while to see why). ;)

Mark

Klaus Linke

unread,
Apr 28, 2002, 1:39:14 AM4/28/02
to
"Mark Tangard" <mtan...@speakeasy.net> wrote:
> Thanks, Klaus, this works great (although it took a while to see
why). ;)

I'm not sure I know why it works myself ;-)
and much less why your code didn't...
The revisions in tables seem to exist and not exist at the same time,
like ghosts.

Selection.NextRevision(Wrap:=True) seems to work.
Since I didn't find a way to count the revisions and stop at the last
one, I set Wrap:=True, and checked if I had passed the end of the
document (posNew<posOld).

Like Sesha I think the bug is caused by Word not treating the
end-of-cell markers the same way as paragraph marks. A few days ago,
there was a problem in the tables newsgroup where OutlinePromote and
OutlineDemote didn't work for paragraphs in table cells. I'd be
surprised if there is an easy explanation for bugs like this. Probably
the internal storage format for tables, revisions ... got so complex
that hardly anybody at Microsoft understands what is going on any
more.

Greetings, Klaus

0 new messages