View Single Post
Old 11-28-2006, 10:36 PM   #8
Stingo
Evangelist
Stingo ought to be getting tired of karma fortunes by now.Stingo ought to be getting tired of karma fortunes by now.Stingo ought to be getting tired of karma fortunes by now.Stingo ought to be getting tired of karma fortunes by now.Stingo ought to be getting tired of karma fortunes by now.Stingo ought to be getting tired of karma fortunes by now.Stingo ought to be getting tired of karma fortunes by now.Stingo ought to be getting tired of karma fortunes by now.Stingo ought to be getting tired of karma fortunes by now.Stingo ought to be getting tired of karma fortunes by now.Stingo ought to be getting tired of karma fortunes by now.
 
Stingo's Avatar
 
Posts: 472
Karma: 1152385
Join Date: Nov 2006
Location: Miami
Device: KH2O, KPW2, KDXG, KPW1, K3, S505
Glad the macro is helping. If you relate the macro to a button on your tool bar it really becomes a pleasure to use.

I added a little section to take out double spaces that sometimes occur when there is a space at the end of the line prior to the hard return.

'
' ebook_formatter Macro
' Macro created 11/28/2006 by Jorge Espinosa
'
' This step take you to the top of your document

Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"

' This step clears formatting and sets font to my preferred size
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.WholeStory
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 14
With Selection.Font
.NameFarEast = ""
.NameAscii = "Times New Roman"
.NameOther = "Times New Roman"
.Name = ""
.Size = 14
.Bold = False
.Italic = False
End With

' This step replaces hard page breaks
'
With Selection.Find
.Text = "^m"
.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

' This step replace the correct paragraph mark with a temporary sign "#*#", if your document has that sign, replace
' with some other special character
'
With Selection.Find
.Text = "^p^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

' This step will replace the inappropriate line break with a space.
'
With Selection.Find
.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

' This step will replace the double spaces sometimes created by previous replace.
'
With Selection.Find
.Text = " "
.Replacement.Text = " " ' if there is a space at the end of the line, change this to ""
.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

' This step will return the paragraph break to normal
'
With Selection.Find
.Text = "#*#"
.Replacement.Text = "^p^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
Stingo is offline   Reply With Quote