|
|
|
date: Thu, 20 Mar 2008 18:13:02 -0700,
group: microsoft.public.word.vba.beginners
back
RE: Cycle through the Document Stories
Sorry to keep posting but I did a little more testing I put the following
code line inside the Do Loop of the routine:
Selection.TypeText (rngStory.StoryType & ", ")
I wanted to keep track of which Story Types the routine was cycling through.
I used the Step 3 option from the website you referred me to -- Public Sub
FindReplaceAnywhere().
I placed this code inside the loop right before:
Select Case rngStory.StoryType
which evaluates which Story Type number the routine is on. This was the
results:
when I ran the routine step by step the following Story Type numbers were
typed:
1, 2, 5, 9, 9, 9, 9, 9, 10, 11, 11, 12, 13, 15, 16
When I ran the routine in its entirety non-stop these were the numbers typed:
1, 2,
It's like when the routine runs entirely it just stops after Story Type 2
and ends the routine but when run step by step it cycles through 1 - 16.
Again sorry for all of the postings, but I'm just trying to figure this out
and I think any information I can give you might help narrow things down a
bit.
"frank" wrote:
> I'm trying to create a macro that will clean out the tracked changes created
> by a program called DeltaView. DeltaView is similar to the native Word
> compare and merge feature except it uses styles to show deleted and inserted
> text.
>
> Deleted text is styled as "DeltaView Deletion" style which has style
> attributes of Red font and crossed out text. I want to remove all of the
> text in the document that is styled with the DeltaView Deletion style. I can
> achieve this by using the coding below, but it only removes the desired text
> from the main part of the document. I need to ensure that this text is
> removed from the headers/footers and textboxes/frames.
>
> Why would we show the tracked changes using this program and then want to
> remove them?...That's a longer boring story.
>
> This is the code I use for the main document:
>
> Set myRange = ActiveDocument.Content
>
> With myRange.Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Text = ""
> .Replacement.Text = ""
> .Style = "DeltaView Deletion"
> .Execute Replace:=wdReplaceAll
> End With
>
> Any help is always greatly appreciated.
>
> Thank you.
date: Fri, 21 Mar 2008 12:14:04 -0700
author: frank
Re: Cycle through the Document Stories
That's good sleuthing.
Obviously it's a timing problem, although I don't have a clue about what's
causing it. It would appear that Word is taking too long to go from the
Footnotes story (.StoryType = 2) to the TextFrame story (.StoryType = 5), so
rngStory is equal to Nothing at the end of the loop.
When a loop seems to be running too fast, it can often be cured by inserting a
call to the DoEvents function. The real purpose of DoEvents is to yield the
processor to Windows so it can take care of other things that are waiting.
People with more knowledge of Word's innards than me have said that it shouldn't
make any difference because Word is single-threaded, but my empirical
observation is that it can help -- and it certainly won't hurt.
Just before the line
Set rngStory = rngStory.NextStoryRange
insert a DoEvents statement (it doesn't take parameters or return a value).
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
On Fri, 21 Mar 2008 12:14:04 -0700, frank
wrote:
>Sorry to keep posting but I did a little more testing I put the following
>code line inside the Do Loop of the routine:
>
>Selection.TypeText (rngStory.StoryType & ", ")
>
>I wanted to keep track of which Story Types the routine was cycling through.
> I used the Step 3 option from the website you referred me to -- Public Sub
>FindReplaceAnywhere().
>
>I placed this code inside the loop right before:
>
>Select Case rngStory.StoryType
>
>which evaluates which Story Type number the routine is on. This was the
>results:
>
>when I ran the routine step by step the following Story Type numbers were
>typed:
>
>1, 2, 5, 9, 9, 9, 9, 9, 10, 11, 11, 12, 13, 15, 16
>
>When I ran the routine in its entirety non-stop these were the numbers typed:
>
>1, 2,
>
>It's like when the routine runs entirely it just stops after Story Type 2
>and ends the routine but when run step by step it cycles through 1 - 16.
>
>Again sorry for all of the postings, but I'm just trying to figure this out
>and I think any information I can give you might help narrow things down a
>bit.
>
>
>
>"frank" wrote:
>
>> I'm trying to create a macro that will clean out the tracked changes created
>> by a program called DeltaView. DeltaView is similar to the native Word
>> compare and merge feature except it uses styles to show deleted and inserted
>> text.
>>
>> Deleted text is styled as "DeltaView Deletion" style which has style
>> attributes of Red font and crossed out text. I want to remove all of the
>> text in the document that is styled with the DeltaView Deletion style. I can
>> achieve this by using the coding below, but it only removes the desired text
>> from the main part of the document. I need to ensure that this text is
>> removed from the headers/footers and textboxes/frames.
>>
>> Why would we show the tracked changes using this program and then want to
>> remove them?...That's a longer boring story.
>>
>> This is the code I use for the main document:
>>
>> Set myRange = ActiveDocument.Content
>>
>> With myRange.Find
>> .ClearFormatting
>> .Replacement.ClearFormatting
>> .Text = ""
>> .Replacement.Text = ""
>> .Style = "DeltaView Deletion"
>> .Execute Replace:=wdReplaceAll
>> End With
>>
>> Any help is always greatly appreciated.
>>
>> Thank you.
date: Fri, 21 Mar 2008 19:44:43 -0400
author: Jay Freedman
|
|