Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Replacing Random Text with Your Own Text.

Replacing Random Text with Your Own Text

Written by Allen Wyatt (last updated January 15, 2022)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021


2

GwenDolyn knows how to use the =rand() feature to insert random text. She wonders, however, if there is a way to customize or add text to what is returned by =rand(). She uses that feature as a boilerplate/filler for demonstrations and would like to add her own verbiage.

Unfortunately, there is no way to modify what is returned by =rand() since it is a function built into Word. There are a couple of ways around this issue, however. The most likely candidates are the following: a Building Block, an AutoCorrect entry, or a macro. More on those in a moment.

First, it is important to understand that Word provides three ways you can insert random text in your document. GwenDolyn already knows about the =rand() function, which inserts some text about how to use some of the features in Word. If you prefer to read about quick brown foxes, you can use the function =rand.old() instead. Finally, you can use =lorem() to insert text that is based on the familiar lorem ipsum filler text that designers have used for decades.

If none of these options do the trick for you, one alternative is to create a Building Block entry that contains the boilerplate info you want. This can be as long of an entry as you want, and can even contain "special" elements, such as tables. Building Blocks have the advantage of being easier to insert into a document than it is to use the =rand() function. How you create Building Blocks has been covered in other issues of WordTips.

The AutoCorrect feature of Word can be used to insert a limited amount of boilerplate text, as well. Correctly set up, AutoCorrect is even faster to use than Building Blocks. All you need to do is remember the small mnemonic you create (such as bpt, meaning boilerplate text), type that mnemonic, and it is automatically replaced with the fuller boilerplate.

The drawback to using Building Blocks or AutoCorrect instead of =rand() is that they aren't as flexible; you cannot specify how many paragraphs you want and how many sentences you want per paragraph. If you want that sort of flexibility, you will need to resort to creating a macro that will do the boilerplate insertion. The following is an example of a simple macro to do such a task.

Sub RandomText()
    Dim sSent As String
    Dim iSentences As Integer
    Dim iParagraphs As Integer
    Dim J As Integer
    Dim K As Integer

    iSentences = 3    'Number of sentences per paragraph
    iParagraphs = 5   'Number of paragraphs
    sSent = "Wallace Widgets makes the best widgets in the known world. "

    For J = 1 To iParagraphs
        For K = 1 to iSentences
            Selection.TypeText sSent
        Next K
        Selection.TypeParagraph
    Next J
End Sub

You can, of course, assign this macro to a shortcut key or add it to the Quick Access Toolbar and it would insert your text (designated in the sSent variable) whenever you invoke it. You might even want to modify the macro so that instead of having the number of sentences and paragraphs "hard coded," the macro asks the user to specify how many of each it should use.

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 (9035) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Word here: Replacing Random Text with Your Own Text.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Converting Numbers to Strings

VBA is great at working with both strings and numbers. At some point you may have a number you need to convert to a ...

Discover More

Comma-Delimited Differences for PC and Mac

When you choose to save worksheet data in CSV format, Excel gives you three choices for file formats. Those choices are ...

Discover More

Differences between Tables and Named Ranges

Excel allows you to define the data in a worksheet as a table. Doing so can provide some clear benefits over simply ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (ribbon)

Different Layout for a Portion of a Page

Got a document layout that requires a portion of the page to be in one layout and another portion to be in a different ...

Discover More

Dealing with Run-On Sentences

A common task when editing documents is to break up run-on sentences. You can make this task a little easier by using the ...

Discover More

Inserting a Non-Breaking Hyphen

Non-breaking hyphens can come in handy for some types of writing. They force the words (or characters) on both sides of ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 + 7?

2022-01-17 11:24:44

Ralph Bentley

Look out for lorem. Word automatically turns off spell check in lorem paragraphs to avoid all those squiggly red underlines. When you delete it, that last paragraph is still in lorem mode. No spell check.


2022-01-15 10:35:39

Stephen

Thanks for this good tip article, Allen.

The =lorem() and similar functions stopped working for me several years ago in Word 365. I just found the following fix.
Go to AutoCorrect Options and tick the "Replace text as you type" option box. Then the =rand(), =rand.old(), and =lorem() functions started working again for me.

Cheers!


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

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

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.