{"id":4103,"date":"2014-03-03T04:00:13","date_gmt":"2014-03-03T09:00:13","guid":{"rendered":"http:\/\/americaneditor.wordpress.com\/?p=4103"},"modified":"2016-09-16T11:46:43","modified_gmt":"2016-09-16T17:46:43","slug":"lyonizing-word-the-next-character-macro","status":"publish","type":"post","link":"https:\/\/editorium.com\/archive\/lyonizing-word-the-next-character-macro\/","title":{"rendered":"Lyonizing Word: The Next Character Macro"},"content":{"rendered":"<p>Today\u2019s column by Jack Lyon marks the first essay in a new monthly series, \u201cLyonizing Word.\u201d In this series, Jack will\u00a0discuss using Microsoft Word, especially macros, to best advantage during the editing process. Please welcome\u00a0Jack as a new columnist for An American Editor.<\/p>\n<p style=\"text-align:center;\">______________<\/p>\n<h3 style=\"text-align:center;\">Lyonizing Word: The Next Character Macro<\/h3>\n<p style=\"text-align:center;\"><strong>by Jack Lyon<\/strong><\/p>\n<p>Macros and mastering Microsoft Word are keys to success in the business of editing. One can be a great editor and not master either, but it is more difficult, if not near-impossible, to have a successful editing business if you aren\u2019t master of the tools you use.<\/p>\n<p>My plan is to help you master Word and Word macros. My hope is that you will learn from each of my columns and will take the lessons learned and build on them yourself \u2014 for example, by building more complex and more useful macros that fulfill a need in your editing business. Here\u2019s my first installment, which I hope you\u2019ll find useful.<\/p>\n<h4>The NextCharacter Macro<\/h4>\n<p>I often use character codes while finding and replacing in Microsoft Word. What\u2019s a character code? Here are some common ones:<\/p>\n<p style=\"padding-left:30px;\">^09 is a tab<br \/>\n^13 is a carriage return<br \/>\n^32 is a space<\/p>\n<p>Especially in a wildcard search, you may have to use such codes because Word\u2019s wildcard search engine can\u2019t handle certain characters and will give you an error message if you try to use them.<\/p>\n<p>But what if you don\u2019t know the code for the character you need? You can probably look it up online or in a computer book, but wouldn\u2019t it be nice to have a macro that would tell you immediately? Just put your cursor in front of the character and run the macro to get the code number. Here\u2019s a macro that will do just that:<\/p>\n<blockquote>\n<p style=\"padding-left:30px;\">Sub NextCharacter()<br \/>\nDim NextChar As String<br \/>\nNextChar = Str(AscW(Selection))<br \/>\nMsgBox \u201cThe code for the next character is\u201d &amp;\u00a0NextChar<br \/>\nEnd Sub<\/p>\n<\/blockquote>\n<p>That\u2019s pretty simple, but there\u2019s still a lot going on. Let\u2019s look at each line in the macro.<\/p>\n<p><strong> Sub NextCharacter()<\/strong><\/p>\n<p>Here we tell Word the name of the macro, which is a subroutine (Sub) named NextCharacter. You can use pretty much any name you like, as long as it doesn\u2019t start with a number or include any spaces. And the parentheses at the end of the name? I\u2019ll reserve that discussion for a future article.<\/p>\n<p><strong>Dim NextChar As String<\/strong><\/p>\n<p>I just made up the name NextChar but <i>not<\/i> the commands around it, all of which are part of VBA (Visual Basic for Applications), Microsoft\u2019s programming language for Word and other programs in the Office suite. If you want to learn more about \u201cDim,\u201d \u201cAs,\u201d \u201cString,\u201d and other VBA commands, here\u2019s a good place to start: <a title=\"Getting Started with VBA\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ff604039%28v=office.14%29.aspx\" target=\"_blank\">Getting Started with VBA in Word 2010<\/a>.<\/p>\n<p>In this line, we\u2019re \u201cdimensioning\u201d (Dim) a variable to hold a value (NextChar) that we\u2019ll use later in the macro. A variable is just a placeholder that can hold a value, like X in your high-school algebra class. Dimensioning just tells Word what *kind* of value we\u2019re using \u2014 in this case, a string of characters rather than, say an integer, which can only hold numbers.<\/p>\n<p><strong>NextChar = Str(AscW(Selection))<\/strong><\/p>\n<p>This assigns a value to the NextChar variable. What value? The one produced by this:<\/p>\n<p><strong>Str(AscW(Selection))<\/strong><\/p>\n<p>\u201cSelection\u201d is the character to the right of your cursor (in the Western world).<\/p>\n<p>\u201cAscW\u201d tells Word to find the ASCII or Unicode value of that character.<\/p>\n<p>\u201cStr\u201d turns that value into a string \u2014 that is, characters rather than a value. Why? So we can <i>see<\/i> those characters in the message box produced by the next line:<\/p>\n<p><strong>MsgBox \u201cThe code for the next character is\u201d &amp; NextChar<\/strong><\/p>\n<p>This displays a message box (MsgBox) that gives us the code for the next character (as stored in NextChar), preceded by the text \u201cThe code for the next character is\u201d just to pretty things up.<\/p>\n<p><strong>End Sub<\/strong><\/p>\n<p>This line simply ends the macro, or subroutine.<\/p>\n<p>Now, here\u2019s how to put this macro (or any other) into Microsoft Word so it will be available when you need it:<\/p>\n<ol>\n<li>Copy the text of the macro, starting with the first \u201cSub\u201d and ending with the last \u201cSub.\u201d<\/li>\n<li>Click the \u201cView\u201d tab on Microsoft Word\u2019s ribbon.<\/li>\n<li>Click the \u201cMacros\u201d button.<\/li>\n<li>Type a name for the macro in the \u201cMacro name\u201d box \u2014 probably the name used after the first \u201cSub.\u201d For this macro, that\u2019s \u201cNextCharacter.\u201d<\/li>\n<li>Click the \u201cCreate\u201d button.<\/li>\n<li>Delete the \u201cSub [macro name]\u201d and \u201cEnd Sub\u201d lines that Word created in the macro window. The macro window should now be completely empty (unless you already have other macros in there).<\/li>\n<li>Paste the macro text at the current insertion point.<\/li>\n<li>Click \u201cFile,\u201d then \u201cClose and Return to Microsoft Word.\u201d<\/li>\n<\/ol>\n<p>To actually use the macro:<\/p>\n<ol>\n<li>Place your cursor directly in front of the character you want to identify.<\/li>\n<li>Click the \u201cView\u201d tab on Microsoft Word\u2019s ribbon.<\/li>\n<li>Click the \u201cMacros\u201d button.<\/li>\n<li>Click the name of your macro to select it.<\/li>\n<li>Click the \u201cRun\u201d button. (If you wanted to delete the macro, you could press the \u201cDelete\u201d button instead.)<\/li>\n<\/ol>\n<p>After the macro runs, a dialog box will appear with the numeric code for the character. To dismiss the dialog box, click OK.<\/p>\n<p>Now that you know the code for the character after your cursor, you can use that code in Word\u2019s Find dialog. Or you can insert it into your document. To do so, hold down the ALT key and enter the code on the numeric keypad. For example, the code for an uppercase A is 65. You could insert that character by holding down the ALT key and entering 65 on the numeric keypad. Of course, it\u2019s a lot easier just to hold down SHIFT and hit the A key, but what if you need to enter something more esoteric? Microsoft provides a code chart here: <a title=\"ANSI Character Codes Chart\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa245259%28v=vs.60%29.aspx\" target=\"_blank\">ANSI Character Codes Chart<\/a>.<\/p>\n<p>That\u2019s it! I hope you find the macro useful, and that my explanation here helps you understand a little more about how macros work.<\/p>\n<p><em>Jack Lyon (<a href=\"mailto:editor@editorium.com\">editor@editorium.com<\/a>)\u00a0owns and operates the <a title=\"The Editorium\" href=\"http:\/\/www.editorium.com\" target=\"_blank\">Editorium<\/a>, 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-the-next-character-macro\/\" rel=\"bookmark\" title=\"Permalink to Lyonizing Word: The Next Character Macro\"><p>Macros and mastering Microsoft Word are keys to success in the business of editing. One can be a great editor and not master either, but it is more difficult, if not near-impossible, to have a successful editing business if you aren\u2019t master of the tools you use.<\/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,175,409],"tags":[267,410,411,412],"class_list":{"0":"post-4103","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-computers-and-software","7":"category-contributor-article","8":"category-editing-tools-editorial-matters","9":"category-lyonizing-word","10":"tag-jack-lyon","11":"tag-nextcharacter-macro","12":"tag-understanding-macros","13":"tag-word-macros","14":"h-entry","15":"hentry"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3gfno-14b","_links":{"self":[{"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/posts\/4103","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=4103"}],"version-history":[{"count":1,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/posts\/4103\/revisions"}],"predecessor-version":[{"id":5980,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/posts\/4103\/revisions\/5980"}],"wp:attachment":[{"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/media?parent=4103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/categories?post=4103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/tags?post=4103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}