From: Felix on
Hello,

I have a series of rather large Word documents used in testing. Once testing
is complete, I clean up the documents to remove the testing bits (checkboxes,
approvals and such) and then compile the document in chm form to be used as a
help file.

I've written a macro that cleans up the document by selectively removing
some table rows, and some "This page is intentionally blank" entries. I would
also like to remove a whole lot of unnecessary blank lines, but only starting
at a certain point in the document.

So, I need to first move to the point in the document where I want to begin
removing blank lines, then start removing blank lines (including those with
spaces), and then stop once I reach the end of the document.

Any help is greatly appreciated.
From: macropod on
Hi Felix,

Try the following macro with the insertion point positioned where you want the clean-up to start:
Sub Cleanup()
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "([ ]{1,})([^13])"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
.Text = "([^13])([^13]{1,})"
.Replacement.Text = "\1"
.Execute Replace:=wdReplaceAll
End With
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Felix" <Felix(a)discussions.microsoft.com> wrote in message news:82449BC4-26A4-43C3-A0C3-7CFC2A1D570A(a)microsoft.com...
> Hello,
>
> I have a series of rather large Word documents used in testing. Once testing
> is complete, I clean up the documents to remove the testing bits (checkboxes,
> approvals and such) and then compile the document in chm form to be used as a
> help file.
>
> I've written a macro that cleans up the document by selectively removing
> some table rows, and some "This page is intentionally blank" entries. I would
> also like to remove a whole lot of unnecessary blank lines, but only starting
> at a certain point in the document.
>
> So, I need to first move to the point in the document where I want to begin
> removing blank lines, then start removing blank lines (including those with
> spaces), and then stop once I reach the end of the document.
>
> Any help is greatly appreciated.
From: Felix on
Thanks. This didn't quite give me the expected results. It didn't go through
the entire document, and it affected my formatting somewhat. In some cases,
it wiould delete a blank line just before a line formatted with a header
style, which causes the header to lose it's style (can't figure that one out).

I'm wondering if the presence of multiple tables might be the cause...

"macropod" wrote:

> Hi Felix,
>
> Try the following macro with the insertion point positioned where you want the clean-up to start:
> Sub Cleanup()
> With Selection.Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Text = "([ ]{1,})([^13])"
> .Replacement.Text = "\2"
> .Forward = True
> .Wrap = wdFindStop
> .Format = False
> .MatchCase = False
> .MatchWholeWord = False
> .MatchAllWordForms = False
> .MatchSoundsLike = False
> .MatchWildcards = True
> .Execute Replace:=wdReplaceAll
> .Text = "([^13])([^13]{1,})"
> .Replacement.Text = "\1"
> .Execute Replace:=wdReplaceAll
> End With
> End Sub
>
> --
> Cheers
> macropod
> [Microsoft MVP - Word]
>
>
> "Felix" <Felix(a)discussions.microsoft.com> wrote in message news:82449BC4-26A4-43C3-A0C3-7CFC2A1D570A(a)microsoft.com...
> > Hello,
> >
> > I have a series of rather large Word documents used in testing. Once testing
> > is complete, I clean up the documents to remove the testing bits (checkboxes,
> > approvals and such) and then compile the document in chm form to be used as a
> > help file.
> >
> > I've written a macro that cleans up the document by selectively removing
> > some table rows, and some "This page is intentionally blank" entries. I would
> > also like to remove a whole lot of unnecessary blank lines, but only starting
> > at a certain point in the document.
> >
> > So, I need to first move to the point in the document where I want to begin
> > removing blank lines, then start removing blank lines (including those with
> > spaces), and then stop once I reach the end of the document.
> >
> > Any help is greatly appreciated.
> .
>
From: Fumei2 via OfficeKB.com on
"It didn't go through the entire document"

Of course it did not go through the entire document. That is because you
asked for:

"So, I need to first move to the point in the document where I want to begin
removing blank lines,"

Which macropod gave you, and stated:

"Try the following macro with the insertion point positioned where you want
the clean-up to start:"


Your fomrat issues may come from your use of the word "line". Do you mean
paragraph? Why are there "blank" lines? And are you saying there are
paragraphs with only spaces?



Felix wrote:
>Thanks. This didn't quite give me the expected results. It didn't go through
>the entire document, and it affected my formatting somewhat. In some cases,
>it wiould delete a blank line just before a line formatted with a header
>style, which causes the header to lose it's style (can't figure that one out).
>
>I'm wondering if the presence of multiple tables might be the cause...
>
>> Hi Felix,
>>
>[quoted text clipped - 38 lines]
>> > Any help is greatly appreciated.
>> .

--
Gerry

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/201004/1