{"id":4160,"date":"2014-03-31T04:00:04","date_gmt":"2014-03-31T08:00:04","guid":{"rendered":"http:\/\/americaneditor.wordpress.com\/?p=4160"},"modified":"2016-09-16T11:46:44","modified_gmt":"2016-09-16T17:46:44","slug":"lyonizing-word-deleting-extraneous-carriage-returns-in-footnotes-and-endnotes","status":"publish","type":"post","link":"https:\/\/editorium.com\/archive\/lyonizing-word-deleting-extraneous-carriage-returns-in-footnotes-and-endnotes\/","title":{"rendered":"Lyonizing Word: Deleting Extraneous Carriage Returns in Footnotes and Endnotes"},"content":{"rendered":"<h3 style=\"text-align:center;\">Deleting Extraneous Carriage Returns<br \/>\nin Footnotes and Endnotes<\/h3>\n<p style=\"text-align:center;\"><em><strong>by Jack Lyon<\/strong><\/em><\/p>\n<p>During my editing career, I've often run into problems with footnotes and endnotes in Microsoft Word. Many authors have no clue about how notes are meant to work, and Microsoft certainly hasn't made it obvious. In fact, they've made it easy to mess notes up beyond repair.<\/p>\n<p>One mistake authors make is to insert extraneous carriage returns before or after a note. Why? Because they don't like the positioning of the note on the page, which they're trying to make \"pretty,\" not understanding the problems that will cause in editing and typesetting.<\/p>\n<p>You can try to remove the extraneous returns like this:<\/p>\n<p style=\"padding-left:30px;\">1. Click View &gt; Draft.<br \/>\n2. Click References &gt; Show Notes.<\/p>\n<p>Your cursor should now be in the Notes pane.<\/p>\n<p style=\"padding-left:30px;\">3. Click Home &gt; Replace.<br \/>\n4. In the \"Find What\" box, enter two paragraph codes:<\/p>\n<p style=\"padding-left:60px;\">^p^p<\/p>\n<p style=\"padding-left:30px;\">5. In the \"Replace With\" box, enter one paragraph code:<\/p>\n<p style=\"padding-left:60px;\">^p<\/p>\n<p style=\"padding-left:30px;\">\u00a06. Click the \"Replace All\" button.<\/p>\n<p>Word will replace some of the double returns, but not all of them. And if you try to delete some of the remaining returns, you'll get an error message:<\/p>\n<blockquote><p>\"This is not a valid action for footnotes.\"<\/p><\/blockquote>\n<p>What's going on there is that not all carriage returns are created equal. Some of the returns are \"special\" note returns, and the only way to delete them is to delete the note itself back in the text.<\/p>\n<p>The solution? A macro, of course. But a macro with a twist. As we've seen, the macro can't just find double returns and replace them with a single return. And trying to delete extra returns results in an error. So let's use that error!<\/p>\n<p>Before running the macro, you must be in Draft view, with your cursor at the top of the Notes pane. (How to get there is explained above.)<\/p>\n<p>In the macro, you'll see a couple of \"comments,\" which are explanations or instructions intended for the person reading the code. Comments are preceded by a single quotation mark ('), which tells the macro to ignore the rest of the text on that line. For example, the first comment in the macro reads:<\/p>\n<blockquote><p>'To clean returns in endnotes rather than footnotes, change \".Footnotes\" to \".Endnotes\" in the following line:<\/p><\/blockquote>\n<p>And now, here's the macro:<\/p>\n<p style=\"padding-left:30px;\">Sub CleanReturnsInNotes()<br \/>\n'To clean returns in endnotes rather than footnotes, change \".Footnotes\" to \".Endnotes\" in the following line:<br \/>\nNoteCount = ActiveDocument.Footnotes.Count<br \/>\nSelection.Find.ClearFormatting<br \/>\nSelection.Find.Replacement.ClearFormatting<br \/>\nWith Selection.Find<\/p>\n<p style=\"padding-left:60px;\">.Text = \"^p^p\"<br \/>\n.Replacement.Text = \"\"<br \/>\n.Forward = True<br \/>\n.Wrap = wdFindContinue<br \/>\n.Format = False<br \/>\n.MatchCase = False<br \/>\n.MatchWholeWord = False<br \/>\n.MatchAllWordForms = False<br \/>\n.MatchSoundsLike = False<br \/>\n.MatchWildcards = False<\/p>\n<p style=\"padding-left:30px;\">End With<br \/>\nSelection.Find.Execute<br \/>\nOn Error GoTo TrapTheError<br \/>\nWhile Selection.Find.Found<\/p>\n<p style=\"padding-left:60px;\">Selection.MoveLeft<br \/>\n'The following line may trigger an error!<br \/>\nSelection.Delete<br \/>\nSelection.Find.Execute<\/p>\n<p style=\"padding-left:30px;\">Wend<br \/>\nGoTo TheEnd<br \/>\nTrapTheError:<\/p>\n<p style=\"padding-left:60px;\">ErrorCount = ErrorCount + 1<br \/>\nSelection.MoveRight<br \/>\nSelection.Delete<br \/>\nIf ErrorCount &lt; NoteCount Then Resume Next<\/p>\n<p style=\"padding-left:30px;\">TheEnd:<br \/>\nEnd Sub<\/p>\n<p>Let's look at some of those lines.<\/p>\n<p style=\"padding-left:30px;\">NoteCount = ActiveDocument.Footnotes.Count<\/p>\n<p>NoteCount is a variable; that is, it's a container that can hold a numerical value\u2014in this case, the number of footnotes in the document. We get that value with the VBA command ActiveDocument.Footnotes.Count.<\/p>\n<p style=\"padding-left:30px;\">Selection.Find.ClearFormatting<br \/>\nSelection.Find.Replacement.ClearFormatting<\/p>\n<p>Just to be safe, these lines clear any formatting that might already be applied to the \"Find What\" and \"Replace With\" boxes in Word's find and replace feature.<\/p>\n<p>The following lines, from<\/p>\n<p style=\"padding-left:30px;\">With Selection.Find<\/p>\n<p>down to<\/p>\n<p style=\"padding-left:30px;\">Selection.Find.Execute<\/p>\n<p>simply find any instances of double paragraph returns. The replacement text is set to nothing, as we're not trying to replace those returns with anything:<\/p>\n<p style=\"padding-left:30px;\">\u00a0.Replacement.Text = \"\"<\/p>\n<p>Instead, we're going to try to delete the second return, which (unless the notes are really messed up) is a regular return rather than a special note return:<\/p>\n<p style=\"padding-left:30px;\">\u00a0Selection.MoveRight<br \/>\nSelection.Delete<\/p>\n<p>If it's a special note return, then trying to delete it will cause an error, and the macro will execute this line\u2014<\/p>\n<p style=\"padding-left:30px;\">On Error GoTo TrapTheError<\/p>\n<p>\u2014which sends the macro to this line:<\/p>\n<p style=\"padding-left:30px;\">TrapTheError:<\/p>\n<p>Here's what happens next:<\/p>\n<p style=\"padding-left:30px;\">ErrorCount = ErrorCount + 1<\/p>\n<p>Using the variable ErrorCount, we count the number of errors, adding 1 each time we find one. (ErrorCount is initially empty, or zero.)<\/p>\n<p style=\"padding-left:30px;\">Selection.MoveRight<br \/>\nSelection.Delete<\/p>\n<p>We move right and delete the next return.<\/p>\n<p style=\"padding-left:60px;\">\u00a0If ErrorCount &lt; NoteCount Then Resume Next<\/p>\n<p>If the number of errors is less than the number of notes, we're not through yet, as one of the remaining notes may still have a bad return next to it. So, we tell the macro to Resume operation at the next command after the error occurred. That command is:<\/p>\n<p style=\"padding-left:30px;\">Selection.Find.Execute<\/p>\n<p>In other words, Word looks for the next occurrence of a double return. And this construction\u2014<\/p>\n<p style=\"padding-left:30px;\">While Selection.Find.Found<\/p>\n<p style=\"padding-left:60px;\">Selection.MoveLeft<br \/>\n'The following line may trigger an error!<br \/>\nSelection.Delete<br \/>\nSelection.Find.Execute<\/p>\n<p style=\"padding-left:30px;\">Wend<\/p>\n<p>\u2014ensures that it will keep looking as long as (While) double returns are found. (\"Wend\" is short for \"While End\"\u2014it marks the end of the While construction.)<\/p>\n<p style=\"padding-left:30px;\">GoTo TheEnd<\/p>\n<p>When no more double returns are found, this line is executed. It exists simply to avoid executing the error trap (TrapTheError and the following lines) after the macro is finished, at which point<\/p>\n<p style=\"padding-left:30px;\">TheEnd:<\/p>\n<p>marks the end of the whole operation.<\/p>\n<p>I hope this explanation has helped you understand better how macros work, and in particular how you can actually use Word errors to force Word to do what you want it to do\u2014something that gives me great pleasure.<\/p>\n<p>Even if you don't understand everything that's going on in this macro, you can still use it to clean up extraneous returns in notes\u2014something that should make your editorial life a little bit easier.<\/p>\n<p><em>Jack Lyon (<\/em><a href=\"mailto:editor@editorium.com\"><em>editor@editorium.com<\/em><\/a><em>)\u00a0owns and operates the <\/em><a title=\"The Editorium\" href=\"http:\/\/www.editorium.com\" target=\"_blank\"><em>Editorium<\/em><\/a><em>, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of <\/em><a title=\"Microsoft Word for Publishing Professionals\" href=\"http:\/\/www.editorium.com\/msword4pubpros.htm\" target=\"_blank\">Microsoft Word for Publishing Professionals<\/a> <em>and of <\/em><a title=\"Macro Cookbook at Barnes &amp; Noble\" href=\"http:\/\/www.barnesandnoble.com\/w\/macro-cookbook-for-microsoft-word-jack-m-lyon\/1107868228?ean=9781434103321\" target=\"_blank\">Macro Cookbook for Microsoft Word<\/a>.<em> Both books will help you learn more about macros and how to use them.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<a href=\"https:\/\/editorium.com\/archive\/lyonizing-word-deleting-extraneous-carriage-returns-in-footnotes-and-endnotes\/\" rel=\"bookmark\" title=\"Permalink to Lyonizing Word: Deleting Extraneous Carriage Returns in Footnotes and Endnotes\"><p>One mistake authors make is to insert extraneous carriage returns before or after a note. Why? Because they don&#8217;t like the positioning of the note on the page, which they&#8217;re trying to make &#8220;pretty,&#8221; not understanding the problems that will cause in editing and typesetting.<\/p>\n<\/a>","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[77,256,22,67,409],"tags":[267,446,447],"class_list":{"0":"post-4160","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-computers-and-software","7":"category-contributor-article","8":"category-editorial-matters","9":"category-guest-article","10":"category-lyonizing-word","11":"tag-jack-lyon","12":"tag-macros","13":"tag-removing-returns-in-notes","14":"h-entry","15":"hentry"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3gfno-156","_links":{"self":[{"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/posts\/4160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/comments?post=4160"}],"version-history":[{"count":1,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/posts\/4160\/revisions"}],"predecessor-version":[{"id":5990,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/posts\/4160\/revisions\/5990"}],"wp:attachment":[{"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/media?parent=4160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/categories?post=4160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/tags?post=4160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}