From: Sandi V on
Good afternoon - I am trying to create a macro that cleans up a messy
document. What I've got so far is from recording a couple of short macros &
looking at the resulting code.

I recorded a macro to find all instances of two empty paragraphs & replace
with one, which gives me:

With Selection.Find.Text = "^p^p"
.Replacement.Text = "^p

I want this to loop until Word no longer finds two empty paragraph marks.
Can somebody help me with this? (My VBA skills are not great). Thanks in
advance!

Sandi
(code follows)

Sub FixDoc()
'
'Copy everthing but the last paragraph mark
Selection.EndKey Unit:=wdStory
Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
Selection.Copy

'New blank doc, paste unformatted
Documents.Add Template:="z:\templates\NewBlank.dot", NewTemplate:=False, _
DocumentType:=0
Selection.PasteAndFormat (wdPasteDefault)

'Remove direct formatting
Selection.WholeStory
Selection.Font.Reset
Selection.ParagraphFormat.Reset
WordBasic.ToolsBulletsNumbers Replace:=0, Type:=1, Remove:=1

With Selection.Find.Text = "^p^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With

'Apply a Style
Selection.Style = ActiveDocument.Styles("TR Body Text 1,B1")
End Sub
From: Doug Robbins - Word MVP on
In the Replace dialog, click on the More button and then check the Use
wildcards box and replace the ^p^p that you have with ^13{2,}

Leave the ^p in the Replace with control.

For more information on using Wildcards, see the following page of fellow
MVP Graham Mayor's website

http://www.gmayor.com/replace_using_wildcards.htm

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Sandi V" <SandiV(a)discussions.microsoft.com> wrote in message
news:441E8C60-67B2-4B5C-886A-F8BB0801FE08(a)microsoft.com...
> Good afternoon - I am trying to create a macro that cleans up a messy
> document. What I've got so far is from recording a couple of short macros
> &
> looking at the resulting code.
>
> I recorded a macro to find all instances of two empty paragraphs & replace
> with one, which gives me:
>
> With Selection.Find.Text = "^p^p"
> .Replacement.Text = "^p
>
> I want this to loop until Word no longer finds two empty paragraph marks.
> Can somebody help me with this? (My VBA skills are not great). Thanks in
> advance!
>
> Sandi
> (code follows)
>
> Sub FixDoc()
> '
> 'Copy everthing but the last paragraph mark
> Selection.EndKey Unit:=wdStory
> Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
> Selection.Copy
>
> 'New blank doc, paste unformatted
> Documents.Add Template:="z:\templates\NewBlank.dot",
> NewTemplate:=False, _
> DocumentType:=0
> Selection.PasteAndFormat (wdPasteDefault)
>
> 'Remove direct formatting
> Selection.WholeStory
> Selection.Font.Reset
> Selection.ParagraphFormat.Reset
> WordBasic.ToolsBulletsNumbers Replace:=0, Type:=1, Remove:=1
>
> With Selection.Find.Text = "^p^p"
> .Replacement.Text = "^p"
> .Forward = True
> .Wrap = wdFindContinue
> .Format = False
> .MatchCase = False
> .MatchWholeWord = False
> .MatchWildcards = False
> .MatchSoundsLike = False
> .MatchAllWordForms = False
> End With
>
> 'Apply a Style
> Selection.Style = ActiveDocument.Styles("TR Body Text 1,B1")
> End Sub

From: Sandi V on
Thanks ver much! That is exactly what I needed.

"Doug Robbins - Word MVP" wrote:

> In the Replace dialog, click on the More button and then check the Use
> wildcards box and replace the ^p^p that you have with ^13{2,}
>
> Leave the ^p in the Replace with control.
>
> For more information on using Wildcards, see the following page of fellow
> MVP Graham Mayor's website
>
> http://www.gmayor.com/replace_using_wildcards.htm
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
>
> "Sandi V" <SandiV(a)discussions.microsoft.com> wrote in message
> news:441E8C60-67B2-4B5C-886A-F8BB0801FE08(a)microsoft.com...
> > Good afternoon - I am trying to create a macro that cleans up a messy
> > document. What I've got so far is from recording a couple of short macros
> > &
> > looking at the resulting code.
> >
> > I recorded a macro to find all instances of two empty paragraphs & replace
> > with one, which gives me:
> >
> > With Selection.Find.Text = "^p^p"
> > .Replacement.Text = "^p
> >
> > I want this to loop until Word no longer finds two empty paragraph marks.
> > Can somebody help me with this? (My VBA skills are not great). Thanks in
> > advance!
> >
> > Sandi
> > (code follows)
> >
> > Sub FixDoc()
> > '
> > 'Copy everthing but the last paragraph mark
> > Selection.EndKey Unit:=wdStory
> > Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
> > Selection.Copy
> >
> > 'New blank doc, paste unformatted
> > Documents.Add Template:="z:\templates\NewBlank.dot",
> > NewTemplate:=False, _
> > DocumentType:=0
> > Selection.PasteAndFormat (wdPasteDefault)
> >
> > 'Remove direct formatting
> > Selection.WholeStory
> > Selection.Font.Reset
> > Selection.ParagraphFormat.Reset
> > WordBasic.ToolsBulletsNumbers Replace:=0, Type:=1, Remove:=1
> >
> > With Selection.Find.Text = "^p^p"
> > .Replacement.Text = "^p"
> > .Forward = True
> > .Wrap = wdFindContinue
> > .Format = False
> > .MatchCase = False
> > .MatchWholeWord = False
> > .MatchWildcards = False
> > .MatchSoundsLike = False
> > .MatchAllWordForms = False
> > End With
> >
> > 'Apply a Style
> > Selection.Style = ActiveDocument.Styles("TR Body Text 1,B1")
> > End Sub
>