{"id":5845,"date":"2014-03-05T00:01:28","date_gmt":"2014-03-05T07:01:28","guid":{"rendered":"http:\/\/www.wambooli.com\/blog\/?p=5845"},"modified":"2014-03-01T14:49:05","modified_gmt":"2014-03-01T21:49:05","slug":"assigning-a-word-macro-to-a-button","status":"publish","type":"post","link":"https:\/\/www.wambooli.com\/blog\/?p=5845","title":{"rendered":"Assigning a Word Macro to a Button"},"content":{"rendered":"<p>I prefer using keyboard shortcuts for my macros, but there are only so many keys on the keyboard. The Ribbon, however, remains a vast, fertile land into which you can add all sorts of buttons, as does Word&#8217;s Quick Launch bar.<br \/>\n<!--more--><br \/>\nFor this week&#8217;s Word Macro lesson, you&#8217;ll need to fire up a new document. The goal is to create a macro and assign it to a button on the Ribbon. This process is but a small appetizer, teasing you into the full-on power of the Word macro.<\/p>\n<p>This macro example deletes a line of text, so it&#8217;s pretty simple but not particularly useful to anyone. The point is getting that command onto a toolbar button.<\/p>\n<p>Start by opening a new document, which you don&#8217;t need to save. If you need review on how to display the Developer tab on the Ribbon, <a href=\"http:\/\/www.wambooli.com\/blog\/?p=5788\">click here<\/a>. <a href=\"http:\/\/www.wambooli.com\/blog\/?p=5822\">Click here<\/a> for a review on how to create a basic macro. Otherwise, if you&#8217;re up to speed, follow these steps:<\/p>\n<p><strong>1. Fill the document with paragraphs of random text.<\/strong><\/p>\n<p>The simplest way to create random text is to type <strong>=rand()<\/strong> on a line by itself and press the Enter key.<\/p>\n<p><strong>2. Click the Developer tab.<br \/>\n3. Click the Record Macro button.<br \/>\n4. For the Macro name type <code>Delete_Line<\/code>.<br \/>\n5. From the Store Macro In drop-down menu, choose <code>Document1 (document)<\/code> for the current document.<\/strong><\/p>\n<p>So far things look similar to Figure 1, which shows the Record Macro dialog box.<\/p>\n<div id=\"attachment_5863\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5863\" src=\"http:\/\/www.wambooli.com\/blog\/wp-content\/uploads\/2014\/02\/0305-figure1.png\" alt=\"Figure 1. The Record Macro dialog box.\" width=\"400\" height=\"297\" class=\"size-full wp-image-5863\" srcset=\"https:\/\/www.wambooli.com\/blog\/wp-content\/uploads\/2014\/02\/0305-figure1.png 400w, https:\/\/www.wambooli.com\/blog\/wp-content\/uploads\/2014\/02\/0305-figure1-300x222.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><p id=\"caption-attachment-5863\" class=\"wp-caption-text\">Figure 1. The Record Macro dialog box.<\/p><\/div>\n<p><strong>6. Click the Button button.<\/strong><\/p>\n<p>The Word Options dialog box appears, shown in Figure 2. This is the same Word Options dialog box used to change Word&#8217;s settings, but also to customize the Ribbon and (shown in Figure 2) the Quick Access toolbar.<\/p>\n<div id=\"attachment_5865\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.wambooli.com\/blog\/wp-content\/uploads\/2014\/03\/0305-figure2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-5865\" src=\"http:\/\/www.wambooli.com\/blog\/wp-content\/uploads\/2014\/03\/0305-figure2-300x244.png\" alt=\"Figure 2. Adding the macro to the Quick Access toolbar. (Click to embiggen.)\" width=\"300\" height=\"244\" class=\"size-medium wp-image-5865\" srcset=\"https:\/\/www.wambooli.com\/blog\/wp-content\/uploads\/2014\/03\/0305-figure2-300x244.png 300w, https:\/\/www.wambooli.com\/blog\/wp-content\/uploads\/2014\/03\/0305-figure2.png 840w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-5865\" class=\"wp-caption-text\">Figure 2. Adding the macro to the Quick Access toolbar. (Click to embiggen.)<\/p><\/div>\n<p>The <code>Delete_Line<\/code> macro appears on the left in Figure 2. The buttons on the Quick Access toolbar show up on the right.<\/p>\n<p><strong>7. Click to select the <code>Delete_Line<\/code> macro on the left side of the dialog box.<br \/>\n8. Click the Add button (in the middle of the dialog box).<br \/>\n9. You can use the Up or Down buttons to move the <code>Delete_Line<\/code> macro up or down in the list.<br \/>\n10. Click the OK button.<\/strong><\/p>\n<p>The <code>Delete_Line<\/code> macro now appears atop the Word window, nestled in the Quick Actions toolbar. You&#8217;re now ready to record the macro:<\/p>\n<p><strong>11. Press the Home key to ensure that the cursor is at the start of the line.<br \/>\n12. Press Shift+End to select to the end of the line.<br \/>\n13. Press Delete to remove the line.<br \/>\n14. Click the Stop Recording button.<\/strong><\/p>\n<p>The <code>Delete_Line<\/code> macro is now created, saved as a button on the Quick Access toolbar. To use it, click the button.<\/p>\n<p>Two quick answers for you:<\/p>\n<p><em>Yes<\/em>! You can change the look of the button. Word features a button editor that lets you create unique buttons.<\/p>\n<p><em>Yes<\/em>! You can place the button on the Ribbon. You can even create your own, custom Ribbon tab just for your own commands.<\/p>\n<p>I&#8217;ll be divulging these and other Word macro secrets over the next few weeks.<\/p>\n<p>Feel free to discard the document and the macro, or save them. It&#8217;s up to you. But if you choose to save, you encounter something called the <em>macro-enabled Word document<\/em>. I discuss that topic next week.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Word macros can be assigned to keyboard shortcuts or toolbar buttons, take your pick.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[9,19],"class_list":["post-5845","post","type-post","status-publish","format-standard","hentry","category-main","tag-word","tag-word_macro"],"_links":{"self":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5845"}],"version-history":[{"count":5,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5845\/revisions"}],"predecessor-version":[{"id":5882,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5845\/revisions\/5882"}],"wp:attachment":[{"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wambooli.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}