PDA

View Full Version : Solved: Works on main text story, but need it to loop through all other stories in a Word doc



Ice-Tea-Jan
06-28-2009, 07:41 AM
:help

The code below successfully converts tracked changes into "regular text" as follows: sets insertions with a wavy underlines, and set deletions with a strikethrough.

It works beautifully, however, I need to loop it through all other stories in a document because the documents I receive vary, and could have footnotes, different types of headers and footers, text boxes, etc.

I have tried MANY codes to loop this code through different stories, and have been unsuccessful.:banghead:

Can somebody show me how to loop it through any story other than the main text story? From there, I can certainly duplicate it for all the other remaining stories in a document.

Here is the main code that I am trying to loop through all other stories:


Dim myrev As Revision
ActiveDocument.TrackRevisions = False
For Each myrev In ActiveDocument.Revisions
If myrev.Type = wdRevisionDelete Then
myrev.Range.Font.StrikeThrough = True
myrev.Range.Revisions.RejectAll
Else
myrev.Range.Underline = wdUnderlineWavy
myrev.Range.Revisions.AcceptAll
End If
Next

As you may have guessed I am a newbie, but know enough code to get me into trouble!:dunno

Thanking You,
Janet

macropod
06-29-2009, 06:47 AM
Hi Janet,

Try:
Dim pRange As Range, oRev As Revision
For Each pRange In ActiveDocument.StoryRanges
Do
For Each oRev In pRange.Revisions
If oRev.Type = wdRevisionDelete Then
oRev.Range.Font.StrikeThrough = True
oRev.Range.Revisions.RejectAll
Else
oRev.Range.Underline = wdUnderlineWavy
oRev.Range.Revisions.AcceptAll
End If
Next
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next

Ice-Tea-Jan
06-30-2009, 06:47 PM
:cloud9: SPLENDID! It worked beautifully! I struggled with this problem for WEEKS!

I studied your code and recognize (now) how it works. I tested it on all stories -- and it works on all stories!

This was a very concise way to handle this coding.

I am so happy to find this forum. I am at the point where I know enough to get me in trouble, and really need a push.

This forum gives support that reading a VB code book can not ever accomplish.

I'm not sure how to mark this thread solved -- but I put it in the title.

I don't know if I could contribute VB advice to anyone, but I sure am contributing via PayPal!

Thanks again macropod, and thaks for the lighting-fast answer!

Janet :friends:

fumei
07-02-2009, 11:51 AM
"I don't know if I could contribute VB advice to anyone, but I sure am contributing via PayPal!"

With that attitude, and time to improve your skills, I would say you will indeed contribute eventually.

My hats off to you. You gave a truly appreciative response to macropod, and I for one would like to give appreciation back to YOU.