{"id":108,"date":"2002-04-10T12:00:00","date_gmt":"2002-04-10T12:00:00","guid":{"rendered":"http:\/\/editorium.com\/archive\/?p=108"},"modified":"2013-10-25T23:10:20","modified_gmt":"2013-10-25T23:10:20","slug":"fraction-macro","status":"publish","type":"post","link":"https:\/\/editorium.com\/archive\/fraction-macro\/","title":{"rendered":"Fraction Macro"},"content":{"rendered":"<p>Last week's newsletter explained how to make your own typographical fractions in Microsoft Word. You can read about the technique here:<\/p>\n<p>http:\/\/www.topica.com\/lists\/editorium\/read\/message.html?mid=1709983687<\/p>\n<p>But if your document is full of plain-text fractions, like these--<\/p>\n<p>1\/3 2\/3 5\/8<\/p>\n<p>--why not let a macro do the work? I owe my thanks to Wordmeister Steve Hudson for the idea. Steve would probably take a more elegant approach, but this macro will definitely work. Enjoy! If you don't know how to use macros like this one, you can learn how <a href=\"https:\/\/editorium.com\/archive\/using-found-macros\/\" target=\"_blank\">here.<\/a><\/p>\n<p>And now, the macro:<\/p>\n<pre><span style=\"color: black; font-family: Courier New; font-size: small;\">'THE MACRO STARTS HERE\nSelection.Find.ClearFormatting\nSelection.Find.Replacement.ClearFormatting\nWith Selection.Find\n.Text = \"([0-9]@)\/([0-9]@)\"\n.Replacement.Text = \"|sp|1|sp|\" + ChrW(8260) + \"|sb|2|sb|\"\n.Forward = True\n.Wrap = wdFindContinue\n.Format = False\n.MatchCase = False\n.MatchWholeWord = False\n.MatchAllWordForms = False\n.MatchSoundsLike = False\n.MatchWildcards = True\nEnd With\nSelection.Find.Execute Replace:=wdReplaceAll\nSelection.Find.ClearFormatting\nSelection.Find.Replacement.ClearFormatting\nWith Selection.Find.Replacement.Font\n.Superscript = True\n.Subscript = False\nEnd With\nWith Selection.Find\n.Text = \"|sp|([0-9]@)|sp|\"\n.Replacement.Text = \"1\"\n.Forward = True\n.Wrap = wdFindContinue\n.Format = True\n.MatchCase = False\n.MatchWholeWord = False\n.MatchAllWordForms = False\n.MatchSoundsLike = False\n.MatchWildcards = True\nEnd With\nSelection.Find.Execute Replace:=wdReplaceAll\nSelection.Find.ClearFormatting\nSelection.Find.Replacement.ClearFormatting\nWith Selection.Find.Replacement.Font\n.Superscript = False\n.Subscript = True\nEnd With\nWith Selection.Find\n.Text = \"|sb|([0-9]@)|sb|\"\n.Replacement.Text = \"1\"\n.Forward = True\n.Wrap = wdFindContinue\n.Format = True\n.MatchCase = False\n.MatchWholeWord = False\n.MatchAllWordForms = False\n.MatchSoundsLike = False\n.MatchWildcards = True\nEnd With\nSelection.Find.Execute Replace:=wdReplaceAll\n'THE MACRO ENDS HERE\n<\/pre>\n<p><\/span><\/p>\n<p>What's basically going on here is that Word uses a wildcard search to find all numbers that have a slash between them:<\/p>\n<p>Find What: ([0-9]@)\/([0-9]@)<\/p>\n<p>Then it replaces those numbers with *themselves* surrounded by arbitrary codes denoting superscript (|sp|) and subscript (|sb|). It also replaces the slashes with the fraction bar character, Unicode number 8260:<\/p>\n<p>Replace With: \"|sp|1|sp|\" + ChrW(8260) + \"|sb|2|sb|\"<\/p>\n<p>(If you were doing this by hand, you could insert the fraction bar into your document using Insert > Symbol [as explained in last week's newsletter], then copying it, and then pasting it into the Replace dialog's \"Replace With\" box. The result would look something like this: |sp|1|sp|\/|sb|2|sb|)<\/p>\n<p>Finally, the macro uses parentheses to group the numbers so that after they and their surrounding codes are found, the numbers can be replaced by *themselves,* properly formatted and without the codes, using the \"Find What Expression\" wildcard:<\/p>\n<p>Find What: |sp|([0-9]@)|sp|<\/p>\n<p>Replace With: 1 [formatted as superscript]<\/p>\n<p>Find What: |sb|([0-9]@)|sb|<\/p>\n<p>Replace With: 1 [formatted as subscript]<\/p>\n<p>You can learn more about wildcard searches here:<\/p>\n<p>http:\/\/www.topica.com\/lists\/editorium\/read\/message.html?mid=1705963026<\/p>\n<p>http:\/\/www.topica.com\/lists\/editorium\/read\/message.html?mid=1706069286<\/p>\n<p>http:\/\/www.topica.com\/lists\/editorium\/read\/message.html?mid=1706167662<\/p>\n<p>http:\/\/www.topica.com\/lists\/editorium\/read\/message.html?mid=1706267069<\/p>\n<p>http:\/\/www.topica.com\/lists\/editorium\/read\/message.html?mid=1706365638<\/p>\n<p>http:\/\/www.topica.com\/lists\/editorium\/read\/message.html?mid=1706458823<\/p>\n<\/p>\n<p>_________________________________________<\/p>\n<p>READERS WRITE<\/p>\n<p>Gentle reader, I've run into a fairly serious problem that I'm hoping you may have some ideas about. The problem is that QuarkXPress doesn't import Unicode characters--the old 256 are all it will deal with. Several people have asked me if there's a way to find and replace Unicode characters in Word with other lower-level characters that Quark could deal with. For example, if you type a, b, c in Quark and then format it with a Greek font, you get alpha, beta, gamma. Maybe a similar approach could be taken with Unicode characters, if you could figure out what to replace them with in Word (and actually do the replacing) before importing the Word document into Quark. I don't know--this looks like an almost insurmountable problem to me. If you are successfully importing Unicode characters into QuarkXPress, especially using XPress Tag files, I'd love to hear from you. Please write to me here: mailto:editor [at symbol] editorium.com<\/p>\n<p>Sage Rountree (srountree@dukeupress.edu) wrote:<\/p>\n<p>\"When we insert notes to compositor and authors in electronic manuscript files, we want those inserts to be bold and in either angle brackets (for coding and notes to compositor) or curly brackets (for queries to authors). Sometimes, our freelance copyeditors neglect to toggle on the bold for these queries, and we go through and manually convert them to boldface. (By manually, I mean we search for the opening bracket, highlight, and toggle--a big waste of time.)<\/p>\n<p>\"I'm able to figure the search-and-replace for toggling short coding with fixed letters (<a>, <b>) to boldface, but how can I replace all text between the brackets <> and {} *with the brackets themselves* and the text they contain in bold? The substance of the note can sometimes be a few sentences long, and I don't know how to denote that with wildcards. It's like the opposite of the process you outlined in the 10\/25\/2000 newsletter on replacing with \"find what text.\"<\/p>\n<p>\"This has been an interesting mental puzzle for me, but I'm ready to throw in the towel.<\/p>\n<p>Minutes later, before I could respond, Sage wrote again:<\/p>\n<p>\"Jack, I spoke too soon about throwing in the towel, and I added the backslash so Word would recognize the angle brackets as characters, not as the start and end of words. To that end, I wrote this macro:<\/p>\n<p>Selection.HomeKey Unit:=wdStory<\/p>\n<p>Selection.Find.ClearFormatting<\/p>\n<p>Selection.Find.Replacement.ClearFormatting<\/p>\n<p>Selection.Find.Replacement.Font.Bold = True<\/p>\n<p>With Selection.Find<\/p>\n<p>.Text = \"<*>\"<\/p>\n<p>.Replacement.Text = \"^&\"<\/p>\n<p>.Forward = True<\/p>\n<p>.Wrap = wdFindContinue<\/p>\n<p>.Format = True<\/p>\n<p>.MatchCase = False<\/p>\n<p>.MatchWholeWord = False<\/p>\n<p>.MatchWildcards = True<\/p>\n<p>.MatchSoundsLike = False<\/p>\n<p>.MatchAllWordForms = False<\/p>\n<p>End With<\/p>\n<p>Selection.Find.Execute Replace:=wdReplaceAll<\/p>\n<p>Many thanks to Sage for this useful macro (which I edited slightly). I'd add that if your comments are between curly brackets, you could replace the sixth line with this:<\/p>\n<p>.Text = \"{*}\"<\/p>\n<\/p>\n<p>_________________________________________<\/p>\n<p>RESOURCES<\/p>\n<p>So, you kind of like all this programming stuff, eh? Want to learn more? There's an excellent tutorial, \"Getting to Grips with VBA Basics in 15 Minutes,\" by Word expert Bill Coan, at the MVPS Web site. You'll find the tutorial here:<\/p>\n<p>http:\/\/www.mvps.org\/word\/FAQs\/MacrosVBA\/VBABasicsIn15Mins.htm<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<a href=\"https:\/\/editorium.com\/archive\/fraction-macro\/\" rel=\"bookmark\" title=\"Permalink to Fraction Macro\"><p>Last week&#8217;s newsletter explained how to make your own typographical fractions in Microsoft Word. You can read about the technique here: http:\/\/www.topica.com\/lists\/editorium\/read\/message.html?mid=1709983687 But if your document is full of plain-text fractions, like these&#8211; 1\/3 2\/3 5\/8 &#8211;why not let a macro do the work? I owe my thanks to Wordmeister Steve Hudson for the idea. [&hellip;]<\/p>\n<\/a>","protected":false},"author":1,"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":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[],"class_list":{"0":"post-108","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-typesetting","7":"h-entry","8":"hentry"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3gfno-1K","_links":{"self":[{"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/posts\/108","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":3,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":805,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/posts\/108\/revisions\/805"}],"wp:attachment":[{"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/editorium.com\/archive\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}