11-26-2008, 11:34 AM | #1 |
Karmaniac
Posts: 2,553
Karma: 11499146
Join Date: Oct 2008
Location: Miami FL
Device: PRS-505, Jetbook, + Mini, +Color, Astak Ez Reader Pro, PPW1, Aura H2O
|
Emdash - punctuation macro
Hi,
My first,very easy macro in Word. replaces doubledash with emdashes, and takes care of punctuation errors like 'space''dot' and changes it to 'dot'. Following corrections are made: ' .' to '.' ' !' to '!' ' ?' to '?' ' :' to ':' ' ;' to ';' '--' to '—' ' ,' to ',' Also, multiple spaces converted to a single space. Punctiation Macro Code:
' ' ' punctuation Macro ' remove textual errors ' Selection.HomeKey Unit:=wdStory Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = " !" .Replacement.Text = "!" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = " ?" .Replacement.Text = "?" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = " " .Replacement.Text = " " .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = " " .Replacement.Text = " " .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = " " .Replacement.Text = " " .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = " ." .Replacement.Text = "." .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "--" .Replacement.Text = "—" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = " ;" .Replacement.Text = ";" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = " :" .Replacement.Text = ":" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = " ," .Replacement.Text = "," .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub It's a rather simple macro, and my first too,and probably gains you about 3 minutes of work over doing it manually. I've used the recording of macro to do this, probably if you're tech savvy you can create the same command in like 2 or 3 lines or so... Ideas and modifications are welcome! Last edited by ProDigit; 11-27-2008 at 09:18 AM. Reason: Added multispace to single space |
11-26-2008, 03:20 PM | #2 |
Literacy = Understanding
Posts: 4,833
Karma: 59674358
Join Date: Dec 2007
Location: The World of Books
Device: Nook, Nook Tablet
|
Macro writing resources
If you are interested in writing Word macros, I suggest you invest in Mastering VBA by Guy Hart-Davis (ISBN: 9780782144369). Although it is from 2005, it is the bible for writing VBA macros.
If you are interested in Word macros that will help you prepare text for publishing books, I highly recommend Microsoft Word for Publishing Professionals by Jack Lyon (ISBN: 9781434102362). Jack was an editor for a publisher in Utah for 25+ years and wrote many macro programs that have been used by thousands of editors to speed the manuscript preparation process. The book is newly published (September 2008 I believe) and is loaded with valuable information and macro routines. Jack's website (www.editorium.com) has some excellent macros for sale, including one called File Cleaner which includes numerous routines to make clean up of files quick and easy. And, of course, depending on what you ultimately want to do, I'd recommend my own macros available at www.wordsnSync.com. However, these are not designed for basic functions; rather, they are geared to insure editorial consistency. |
Advert | |
|
11-26-2008, 03:23 PM | #3 |
Karmaniac
Posts: 2,553
Karma: 11499146
Join Date: Oct 2008
Location: Miami FL
Device: PRS-505, Jetbook, + Mini, +Color, Astak Ez Reader Pro, PPW1, Aura H2O
|
No thank you,I'm not really into macro's and all..
there's already enough work to do for me right now,that Macro's can not replace It's kind of a pitty, but I just wrote a Macro, and seemingly it's a bit of a useless one if you plan on using the document later on in BD... But since I can't delete the post I'll leave it here. |
11-26-2008, 03:48 PM | #4 |
Resident Curmudgeon
Posts: 73,660
Karma: 127838196
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
One other addition you might want to make is ' ,' to ','
|
11-26-2008, 04:18 PM | #5 |
Karmaniac
Posts: 2,553
Karma: 11499146
Join Date: Oct 2008
Location: Miami FL
Device: PRS-505, Jetbook, + Mini, +Color, Astak Ez Reader Pro, PPW1, Aura H2O
|
' ,' to ',' was already in the code.
I added it in the post. |
Advert | |
|
11-26-2008, 11:02 PM | #6 |
Karmaniac
Posts: 2,553
Karma: 11499146
Join Date: Oct 2008
Location: Miami FL
Device: PRS-505, Jetbook, + Mini, +Color, Astak Ez Reader Pro, PPW1, Aura H2O
|
Nearly all spaces in a document are now been converted to 1 space. Saves some bytes.
|
11-27-2008, 02:52 AM | #7 |
Junior Member
Posts: 2
Karma: 10
Join Date: Nov 2008
Location: Berlin / GER
Device: Sony PRS 500
|
A nice feature would be, if you can delete unneeded line feeds too.
But it is a little bit more complicated. You have to delete all line breaks, if the last character on the previous line is no end-character. [.,-"!?;] Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text. Text Text Text Text Text Text Text Text Text Text Text Text! Text Text Text Text Text Text Text? "Text Text" Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text. into Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text. Text Text Text Text Text Text Text Text Text Text Text Text! Text Text Text Text Text Text Text? "Text Text" Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text. |
11-27-2008, 09:17 AM | #8 |
Karmaniac
Posts: 2,553
Karma: 11499146
Join Date: Oct 2008
Location: Miami FL
Device: PRS-505, Jetbook, + Mini, +Color, Astak Ez Reader Pro, PPW1, Aura H2O
|
that's actually pretty easy to do in Word,
however, I don't know if the macro can do that the way I would solve it, since the macro doesn't always do identically what you ask it. basically you need to convert ^m to .. say a space, and then use trick above to erase double spaces. A code like this already exists. I don't like working with hard return text files, I'd rather choose html. Last edited by ProDigit; 11-27-2008 at 09:20 AM. |
11-28-2008, 02:32 AM | #9 |
Junior Member
Posts: 2
Karma: 10
Join Date: Nov 2008
Location: Berlin / GER
Device: Sony PRS 500
|
No, i don't want to convert all Line breaks into spaces and remove them, only the additional wrong ones and i want to store the real paragraphs. The Paragraphs after a special character are real.
Sometimes the Words AutoForm will remove it, sometimes not - and i have no clue, why or why not sometimes.... |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Punctuation | Dresden | Calibre | 7 | 08-31-2010 05:14 AM |
Word Formatting Macro (Stingo's Macro) | Stingo | Sony Reader | 75 | 08-24-2010 05:18 AM |
Sigil, UTF-8 and the emdash | crutledge | Sigil | 5 | 06-30-2010 12:35 PM |
Encoding of Emdash | crutledge | Workshop | 10 | 10-27-2009 08:31 PM |
More emdash woes | Patricia | Sony Reader | 10 | 07-06-2007 04:32 PM |