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: Replacing Random Text with Your Own Text.

Replacing Random Text with Your Own Text

Written by Allen Wyatt (last updated October 18, 2018)
This tip applies to Word 97, 2000, 2002, and 2003


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: AutoText, AutoCorrect, and macros.

You can create an AutoText 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. AutoText entries have the advantage of being easier to insert into a document than it is to use the =rand() function. How you create AutoText entries has been covered in other issues of WordTips. You can also refer to the following helpful page at the Word MVP site:

http://wordmvp.com/FAQs/Formatting/DummyText.htm

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 is AutoText. 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 AutoText 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 to a toolbar button 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 (9034) 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: 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

Specifying Print Quantity in a Cell

When you print a worksheet, you can specify in the Print dialog box how many copies you want printed. If you want the ...

Discover More

Stepping Through Head Formats

You can use the shortcuts described in this tip to quickly change the heading levels of the headings in your document. ...

Discover More

Controlling Data Entry in a Cell

Sometimes you want whatever is displayed in one cell to control what is displayed in a different cell. This tip looks at ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (menu)

Highlighting Duplicate Words

One way to help improve your writing is to minimize the number of duplicated words you use in your prose. Depending on ...

Discover More

Wrapping Spaces

Add more than one space after the end of a sentence, and you may find that the extra spaces wrap to the start of new ...

Discover More

Talking to Yourself

Need to keep notes about a document, but you don't want others to see those notes either on-screen or on-paper? Here's an ...

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?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon 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.