Text Macro

Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Inserting Text with a Macro.

A custom text macro is a line of text assigned to a quickslot.When the quickslot is used, this text is processed the same as text entered into the chat bar, with the exception that the channel defaults to 'shout' (heard by every player on the server) rather than the channel selected to the left of the chat bar. A textmacro is a shortcut for a sequence of keystrokes. A macro can be simple—it can type a word or phrase you use often—or it can be complex, such as a formatted address. A macro code is the name of the text macro you create.

by Allen Wyatt
(last updated June 10, 2019)

Text macro program

Jun 10, 2019 Inserting text is a common occurrence in macros. You may need the macro to insert numbers, do some standardization on wording, or some other text insertion. The following VBA code lines each insert a different type of text: Selection.TypeText Text:='this text' Selection.TypeText Text:=MyText Selection.InsertParagraph. VBA Text How to use Text Function in VBA Excel Excel Details: Text is a worksheet function in excel but it can also be used in VBA while using the range property with it, the function for this function is similar to the worksheet function and it takes the same number of arguments which are the values which needs to be converted and a specified.

Inserting text is a common occurrence in macros. You may need the macro to insert numbers, do some standardization on wording, or some other text insertion. The following VBA code lines each insert a different type of text:

Each of the three lines inserts something at the current insertion point. The first line inserts everything between the quote marks, the second inserts the value of the MyText variable, and the third inserts a paragraph mark (an empty line).

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1406) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Inserting Text with a Macro.

The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

Want to change the ToolTip that appears when you hover the mouse over a button on a toolbar? It's a bit more involved ...

Discover More

Understanding Word's Object Model and how it relates to macros in VBA.

Discover More

Wouldn't it be great if Word could execute a macro every time someone typed in a particular keyword or phrase? Word may ...

Discover More

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click 'Subscribe.'

Macro

I can't solve the following problem: I need to find and then move a piece of text using VBA. The text is formatted (fragments are marked with italic).
How do I do it:
footText = Selection.Text
...
[another] Selection.Text = footText
Of course, only text is transferred. Is it possible to transfer the formatting in the found text as well?

Mike,
This should do what you want.
Sub LeftAndRight()
Dim leftString As String
Dim rightString As String
Dim printWidth As Single
With ActiveDocument.PageSetup
printWidth = .PageWidth - .LeftMargin - .RightMargin - .Gutter
End With
loopback:
leftString = InputBox('Text to the left')
If leftString = ' Then Exit Sub
rightString = InputBox('Text to the right')
If rightString = ' Then Exit Sub
Selection.TypeText leftString & Chr(9) & rightString
With Selection.Paragraphs(1).TabStops
.ClearAll
.Add Position:=printWidth, _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
End With
Selection.TypeText vbCrLf
GoTo loopback
End Sub

I would like to type text left aligned, then type different text right aligned, on the same line, from VBA. Do you know how to do that?
Thanks,
Mike

I have text like this aaa bbb ccc U+21d73
I would like to be able to search thru the text and copy the 21d73 part and a trailing space just after the U+21d73 part and then insert the 21d73 part and then highlight only that part and once selected reveal / convert it to a Chinese Character (CTRL+X). Then loop back to find the next U+ character code.

Well, this used to work great for word 2010 to insert standard comments into a work comment field. Now with 2013, this is, of course, broken. 'the typetext method or property is not avaialble because the current selection is editing a non editable portion of the reviewing pane' which is a complete piece of bunk; it *is* editing the editable portion of the reviewing pane, as evidenced by my typing into it. More de-contented SW from the people who thoguht nausea-inducing cursors were more useful than macros. Arrgh

Get tips on how to choose good abbreviations for your text macros.

By
February 21, 2011
Episode #167
Listen
How to Create Text Macros
We are currently experiencing playback issues on Safari. If you would like to listen to the audio, please use Google Chrome or Firefox.
Subscribe
Hide player

Bernice is infatuated. Fortunately, it's with Melvin, her boyfriend. Melvin's an introvert, and he doesn't talk very much. This is a Godsend for Bernice. Not only does that give her ample opportunity to hear herself talk, but it means Melvin is her perfect, er, man (biologically, at least). I hear him say 'Hello' to her on the way to his desk. She rushes over to me, gushing. 'Did you hear him? He's so romantic! He just promised to help pick out china patterns for our new home.' 'He did? What new home?' 'The one we're going to buy once we return from the Bigfoot-hunting expedition we’ll be taking for our honeymoon!'

What Are Macros?

Bernice is hearing a bit more than what Melvin actually said. He says one word, and she fills in the details. All of the details. Bernice, when infatuated, is a text macro. You surely remember my episode on how to use text macros and templates, a mere 159 episodes ago. Macros let you type a few short characters and have those expand into much longer text.

Some handheld devices like the Blackberry have this capability built in. It's called autocorrect on the Blackberry. You tell the Blackberry what your abbreviation is and what it should expand into, and voila, you're on your way. Many desktop products also offer autocorrect capabilities.

How to Create Text Macros

Once you have the ability to turn abbreviations into full-fledged text, you need to have some abbreviations to expand! Marlena wrote in asking how to choose abbreviations for macros and expanded text. After all, if you use a lot of abbreviations, it becomes hard to keep track.

I have different abbreviation conventions for different kinds of text I might want to type. The easiest is phrases you use over and over again. For example, I use several different email signoffs: 'Best wishes, Stever.' 'All the best, Stever.' 'Cheers, Stever,' and of course, 'I have a restraining order, do not write me again. Stever.' For phrases, my abbreviation is just the first letter of each word. When the phrase comes to mind, it's easy to remember to type just the first letter. 'All the best' becomes a-t-b. For very long phrases, I only use the first few letters: i-h-a-r-o is the abbreviation for 'I have a restraining order, do not write me again, Stever.'

Text

If one of the words is 'for,' or 'you,' or 'see,' I often use the digit 4, the letter u, or the letter c at that point in the abbreviation. Common two-word combinations become super-easy. 'For a' is 4a, 'See you later' is c-u-l, and so on.

How to Come up with Macro Abbreviations

Create macros for phone numbers by abbreviating and using the first three digits of the number after the area code.

But what if you just have one word? You can’t just use the first letter. Omphaloskepsis and omelette would both be abbreviated 'o.' Typing 'Will Bigfoot enjoy a jellybean o?' would come out 'Will Bigfoot enjoy a jellybean omphaloskepsis?' What an absurd sentence. No one would ever want to write that. To abbreviate common words, keep the first letter, remove the vowels, and remove double letters. Weirdly, your brain can usually still read them. F-r-m, for example, clearly means 'from.' Omelette becomes o-m-l-t. Omphaloskepsis becomes ... well ... I'll leave that as an exercise to the reader. Meditate on it for a while.

For days of the week, I use the first four letters as the macro. M-o-n-d is Monday, T-u-e-s is Tuesday. The expanded abbreviation is capitalized correctly, so I type lowercase m-o-n and get properly capitalized Monday. I do the same for the months of the year.

How to Create Macros for Numbers

I'm sure you've realized by now that phone numbers are tricky because they don't have vowels, or first letters. But they do have first digits. Create macros for phone numbers by abbreviating and using the first three digits of the number after the area code. Bernice recommends her massage therapist Scott to friends to everyone. She puts his phone number—212-555-8932—on the macro 555. She also abbreviates her work and cell phone numbers to their first three digits.

How to Create Macros for URLs

Text Macro Maker

If you have URLs you type a lot and need to abbreviate, use u-r-l plus a single character. U-R-L-G for getitdone.quickanddirtytips.com or U-R-L-E for EggBeaters.com (when it's midnight and you're craving a delicious liquid egg taste treat).

This is an example of a general technique: for related abbreviations, start the abbreviation with the same few characters each time so it serves as a memory hook for all of those abbreviations. If you have a home address, a work address, and a post office office box, name your abbreviations a-d-d-r-h, a-d-d-r-w, and a-d-d-r-p, respectively. It's easy to remember the 'addr,' because you know you're typing an address. Then you just add the first letter of the address you want.

How Macros Can Help You Search the Web

Text Macro C++

Suppose you often use Google to search my articles for tips containing a certain word or phrase. To do that, type the phrase into Google, followed by site:getitdone.quickanddirtytips.com. Or to search my personal articles, use site:steverrobbins.com. Abbreviate the 'site:' part as 'siteg' for Get-it-Done Guy and 'sitesr' for SteverRobbins.com and these sites become part of your daily reference.

How Macros Can Get You a Promotion

If you swear a lot, macros will save you! Make your favorite swear words abbreviations for socially acceptable words. You type, 'Dear boss, your instructions are ****. You are ***, and ***, and your mother *******.' With the magic of macros, it comes out 'Dear boss, your instructions are brilliant. You are logical, and capable, and your mother would be proud.' Voila—you blow off steam and get a promotion.

Combine these techniques to save tons of typing time. Just today, Bernice typed d-m, c-l, scott (in lower case), at 555 4a swedish mss. I hurt ms pckng beans to mk bf a jb omlt usng eb. yfb.' What came out was: 'Dearest Melvin, Please call Scott at 212-555-8932 for a Swedish massage. I hurt myself picking beans to make Bigfoot a Jellybean omelette using Egg Beaters. Your snookie-snookums, Bernice.' I know you're thinking that y-f-b should become 'Your fiancee Bernice,' but she hasn't actually raised that issue with Melvin, yet, so I made fiancee a macro for 'snookie-snookums.' She gets to indulge her fantasies and save her relationship. Macros. Gotta love 'em.

Work Less, Do More, and have a Great Life!

Resources

Text Macro Ue4

  • http://www.smileonmymac.com – TextExpander for the Mac
  • http://www.QuicKeys.com – QuicKeys for Mac
  • http://www.macros.com – MacroExpress for Windows
  • http://www.pitrinec.com – Macro Toolworks for Windows

Funny Text Macro

Image courtesy of Shutterstock

Comments are closed.