View Single Post
Old 01-10-2007, 11:35 AM   #37
Aprilbeginnings
Guru
Aprilbeginnings has a complete set of Star Wars action figures.Aprilbeginnings has a complete set of Star Wars action figures.Aprilbeginnings has a complete set of Star Wars action figures.Aprilbeginnings has a complete set of Star Wars action figures.Aprilbeginnings has a complete set of Star Wars action figures.
 
Aprilbeginnings's Avatar
 
Posts: 632
Karma: 404
Join Date: Nov 2006
Location: Southern CA
Device: Sony PRS-500 /prs 650 soon
Quote:
Originally Posted by diabloNL
Make sure you don't have twice "End sub" on the end.
I removed that cause I am trying this over and over. Now I get an invalid character error when I run it on the book. Also does the text have to be txt only or can it also be rft? I did try it on a txt file when I get that error. here is how my macro looks when I saved it. Of course my version of word is 2000 if that makes any difference

Sub FormatforSony()
'
' ebook_formatter Macro
' Macro created 11/29/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 = " "
.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
'this section will remove multiple spaces. If you do not want
'two spaces after the ending period then remove the first and last
'paragraph in this section.
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ". "
.Replacement.Text = "#!#"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With Selection.Find
.Text = "([ ]{2,6})"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "#!#"
.Replacement.Text = ". "
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
'
' FormatforSony Macro
' Macro recorded 1/10/2007 by
'
End Sub
Aprilbeginnings is offline   Reply With Quote