Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Thu, 20 Mar 2008 18:13:02 -0700,    group: microsoft.public.word.vba.beginners        back       


Cycle through the Document Stories   
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: Thu, 20 Mar 2008 18:13:02 -0700   author:   frank

Re: Cycle through the Document Stories   
See http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm.

--
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 Thu, 20 Mar 2008 18:13:02 -0700, 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: Thu, 20 Mar 2008 22:46:36 -0400   author:   Jay Freedman

Re: Cycle through the Document Stories   
This is great.  The coding is much cleaner than what I was trying to do.  I 
made some attempts at creating code that would remove this styled text from 
the Headers/Footers.  

The only problem I'm having with this new coding (which I had with my much 
more clunkier version) is that it is still skipping the Headers/Footers when 
you run the routine.  I tried using the Step 2 and Step 3 coding examples 
from the website you provided.  

Here is the wierd part.  When you run the routine Step by Step using the F8 
key it works and removes the text from the Headers/Footers, but when you just 
run the routine using the Run Sub/User Form button on the VBA toolbar, it 
skips the Headers/Footers. It worked exactly like that with my lame attempt 
at coding it. 

I've never seen a routine work step by step then not work when you just run 
it entirely.  I'm using Office 2003.  Do you know of any bugs like this in 
this version?

"Jay Freedman" wrote:

> See http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm.
> 
> --
> 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 Thu, 20 Mar 2008 18:13:02 -0700, 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 11:09:03 -0700   author:   frank

Re: Cycle through the Document Stories   
I did some more testing and apparently the macro completely ignores all 
Footers in the document, but it does remove the desired text from the Headers 
of the primary pages (All Headers that are NOT set to First Page Headers).  

The text that it is ignoring is not in a text box.  It's just text on a 
paragraph mark located in the headers/footers styled as "DeltaView Deletion". 

The macro still works step by step but when I run it whole it ignores almost 
all of the headers and footers as I described above.


"Jay Freedman" wrote:

> See http://word.mvps.org/faqs/customization/ReplaceAnywhere.htm.
> 
> --
> 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 Thu, 20 Mar 2008 18:13:02 -0700, 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 11:35:01 -0700   author:   frank

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

Re: Cycle through the Document Stories   
"Jay Freedman"  wrote:
> People with more knowledge of Word's innards than me

(wouldn't include 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.

It may be single-threaded, but it definitely starts a lot of tasks that run 
pretty independently of each other.
I'm sure you've seen the list in the Watch window under 
"Application.Tasks"... Some are genuinely other programs that happen to be 
running, but a lot of Word stuff appears there too.

Maybe that's why DoEvents sometimes helps?

Klaus
date: Sat, 22 Mar 2008 05:53:36 +0100   author:   Klaus Linke

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us