I have added some things to the macro for my personal use but thought that It would be good to share it.
What will it do?
It will center all titles, chapter numbers etc. The original Macro alligned everything to the left.
It will justify all paragraphs, but it won't affect your centered titles etc.
Where to add it in the original macro?
Be sure you use the latest original Macro. Add my code just before "End sub" at the end of the original code.
I also attached a sample file where you can try my code on in case it doesn't work with your file. Then you can edit where needed.
Here is the code:
Code:
'This following section will bring left outlined titles/chapters to the center
'and justifies all paragraphs but won't affect titles etc.
With Selection.Find 'This prevents paragraphs from being centered.
.Text = ".^p"
.Replacement.Text = "#*"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find 'Bring left outlined titles/chapters to the center
.Text = "^p^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
While Selection.Find.Execute
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Wend
With Selection.Find 'Restores the paragraph marks at the end of the paragraphs
.Text = "#*"
.Replacement.Text = ".^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1" 'Take cursor at beginning of document
With Selection.Find 'This step will justify all paragraphs, but not titles etc.
.Text = ".^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
While Selection.Find.Execute
Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
Wend
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1" 'Take cursor at beginning of document