From: Grey Old Man on
I am attempting a word macro to tidy up a large volume of text. I have a few
questions that I hope somebody can help me with.

The space bar has been used extensively to indent the text from the left!

I have used:

With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = " [ ]@([! ])"
.Replacement.Text = " \1"
.MatchWildcards = True
.Wrap = wdFindStop
.Format = False
.Forward = True
.Execute Replace:=wdReplaceAll
End With
End With

to remove multiple spaces but this leaves a single space before the first
capitalized letter.

………..Sentence starts here (multiple leading spaces)

becomes

..Sentence starts here (single leading space)

Any ideas on how to remove the offending single space?


Secondly, trailing spaces have been used in a table. What is the equivalent
to paragraph mark ^p or new line mark ^l when confined to a table?

Table text ………


Thanks in anticipation.

From: Graham Mayor on
CTRL+A then CTRL+E then CTRL+L should remove all leading and trailing spaces
whether in the main document area or table cells. No need for a macro.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


"Grey Old Man" <GreyOldMan(a)discussions.microsoft.com> wrote in message
news:D8D1E795-0E99-4B15-B8E6-455BDFC3BB86(a)microsoft.com...
>I am attempting a word macro to tidy up a large volume of text. I have a
>few
> questions that I hope somebody can help me with.
>
> The space bar has been used extensively to indent the text from the left!
>
> I have used:
>
> With Selection
> .HomeKey Unit:=wdStory
> With .Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Text = " [ ]@([! ])"
> .Replacement.Text = " \1"
> .MatchWildcards = True
> .Wrap = wdFindStop
> .Format = False
> .Forward = True
> .Execute Replace:=wdReplaceAll
> End With
> End With
>
> to remove multiple spaces but this leaves a single space before the first
> capitalized letter.
>
> .....Sentence starts here (multiple leading spaces)
>
> becomes
>
> .Sentence starts here (single leading space)
>
> Any ideas on how to remove the offending single space?
>
>
> Secondly, trailing spaces have been used in a table. What is the
> equivalent
> to paragraph mark ^p or new line mark ^l when confined to a table?
>
> Table text ...
>
>
> Thanks in anticipation.
>


From: DeanH on
Little trick for you, changing selected text from Left/Right/Justified to
Centred alignment, then back will remove superfluous spacing and tabs from
the beginning and end of the text paragraph.
This helps especially in table cells where there is not search facility for
End of Cell marker (this has been asked here many times before without ajor
success).
Hopefully you can use this little trick in your macro.

See also http://gregmaxey.mvps.org/Clean_Up_Text.htm for a previously
created "macro" that you can have a look at.

Hope this helps
DeanH


"Grey Old Man" wrote:

> I am attempting a word macro to tidy up a large volume of text. I have a few
> questions that I hope somebody can help me with.
>
> The space bar has been used extensively to indent the text from the left!
>
> I have used:
>
> With Selection
> .HomeKey Unit:=wdStory
> With .Find
> .ClearFormatting
> .Replacement.ClearFormatting
> .Text = " [ ]@([! ])"
> .Replacement.Text = " \1"
> .MatchWildcards = True
> .Wrap = wdFindStop
> .Format = False
> .Forward = True
> .Execute Replace:=wdReplaceAll
> End With
> End With
>
> to remove multiple spaces but this leaves a single space before the first
> capitalized letter.
>
> ………..Sentence starts here (multiple leading spaces)
>
> becomes
>
> .Sentence starts here (single leading space)
>
> Any ideas on how to remove the offending single space?
>
>
> Secondly, trailing spaces have been used in a table. What is the equivalent
> to paragraph mark ^p or new line mark ^l when confined to a table?
>
> Table text ………
>
>
> Thanks in anticipation.
>