Thread: [Solved] Formatting with macros
View Single Post
 
Old 05-13-2012, 12:44 PM
WaltR WaltR is offline Windows Vista Office 2007
Competent Performer
 
Join Date: Dec 2010
Posts: 123
WaltR is on a distinguished road
Default

Thanks for the replies, and sorry for posting in the wrong forum. The text of the macro in question is below. I think that's it anyway, I'm fairly new at all this. Can I edit it in some way to prevent the dialogs? If so, please give instructions if possible. I've never done it before but could probably do it if guided through. Thanks a lot.

Code:
Sub Macro2()
'
' Macro2 Macro
' Ctrl+ M Justify several paragraphs
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
  .Text = "zzz^p"
  .Replacement.Text = "zzz"
  .Forward = True
  .Wrap = wdFindAsk
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
  .Text = "^p"
  .Replacement.Text = " "
  .Forward = True
  .Wrap = wdFindAsk
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
  .Text = "zzz"
  .Replacement.Text = "^p^p"
  .Forward = True
  .Wrap = wdFindAsk
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchWildcards = False
  .MatchSoundsLike = False
  .MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
End Sub

Last edited by macropod; 05-13-2012 at 02:49 PM. Reason: Added code tags & formatting
Reply With Quote