View Single Post
Old 11-28-2006, 08:48 AM   #1
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: 473
Karma: 1152385
Join Date: Nov 2006
Location: Miami
Device: KH2O, KPW2, KDXG, KPW1, K3, S505
Word Formatting Macro (Stingo's Macro)

Here is a Word Macro that was originally created by a member of the Librie group but which I modified a little. This macro removes hard page breaks, hard returns and adjusts the font to Times Roman 14. You can assign the macro to a function key for ease of access. Feel free to tweak to your needs.

'
' ebook_formatter Macro
' Macro created 11/28/2006
'
' 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. Also see remark below
'
With Selection.Find
.Text = "^p"
.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

End Sub
Stingo is online now   Reply With Quote