Thursday, December 2, 2010

The rand “virus”: or how to insert dummy text into a document


Like jokes, urban legends, and virus hoaxes, tips about Word’s little-used or undocumented features periodically makes their way around the Internet, occasioning a wave of postings in Word newsgroups. One of these is =rand(), which is sometimes represented as an Easter egg, sometimes feared as a possible virus. It is neither. It is a Word function (undocumented in the online Help but documented in the Microsoft Knowledge Base) that can be useful in certain circumstances.

The rand function

The Microsoft Knowledge Base article How to Insert Sample Text into a Document in Word explains the use and syntax of the function: “to quickly insert sample text into a document.” To do this, type =rand() in the document where you want the text to appear, and then press Enter.
Note: The rand function works only if you have “Replace text as you type” enabled in Tools | AutoCorrect Options. It will also not work if the insertion point is immediately after a page or column break.
In Word 2003 and earlier (English versions), the inserted text is that hardy perennial: “The quick brown fox jumps over the lazy dog,” which contains every letter in the English alphabet. As the KB article explains, different language versions of Word use different text.
In Word 2007 =rand() produces several paragraphs of text telling you useful things about galleries, Quick Styles, and themes in Word 2007. If you want quick brown foxes instead, you can use the syntax =rand.old().
By default, the sample text contains three paragraphs, each containing five sentences (three paragraphs of three sentences in Word 2007). You can control how many paragraphs and sentences appear by adding numbers inside the parentheses, for instance:
=rand(3,4)
The first number is the number of paragraphs, and the second the number of sentences per paragraph. If you omit the second number, you get five sentences in each paragraph. So, for example:
=rand(3,4)
inserts three four-sentence paragraphs, while:
=rand(10)
inserts ten five-sentence paragraphs.
The maximum number for either parameter is 200 and may be lower depending on the number of paragraphs and sentences specified. For instance, if you specify 200 paragraphs, then the maximum number of sentences per paragraph you can specify is 99:
=rand(200, 99)
If you specify 200 sentences per paragraph, then the maximum number of paragraphs you can specify is 99.
Admittedly, this function serves a useful purpose for filling a page when you’re designing a template and want to see how it will look with text in it. It’s also easy to see how users can be alarmed and fear this is a virus when someone suggests they try “=rand(200,99),” which quickly blows up into a giant document! (Incidentally, part of the instructions in some versions is to “Make sure there is a space between = and rand and a space between rand and (200,99).” This actually makes no difference: the function works equally well with and without spaces.)

A better method of creating dummy text

Although the rand function is quick and easy, the text it produces is not very natural. All the paragraphs are the same length, and, because every sentence is the same, the lines will tend to break in the same places. The result is that some possible formatting problems may be masked. Another, more useful, possibility, therefore, is to use “Greek“ or “lorem ipsum” text.
Because this kind of dummy text is very commonly used by designers (because it gives a natural look without distracting content), you’ve probably seen examples of it. Microsoft even used it in the Microsoft TrueType Font Assistant (version 1.1) in Windows 3.x. According to the Microsoft Knowledge Base article: Description of the "Lorem ipsum dolor sit amet" text that appears in Word Help:
The phrase "Lorem ipsum dolor sit amet consectetuer" appears in Microsoft Word online Help. This phrase has the appearance of an intelligent Latin idiom. Actually, it is nonsense.
“Although the phrase is nonsense,” the article continues, “it does have a long history.” If you’re curious about that history, follow the link above.
Lorem ipsum text is also discussed at The Free Online Dictionary of Computing, which adds that “the point of using this text, or some other text of incidental intelligibility, is that it has a more-or-less normal (for English and Latin, at least) distribution of ascenders, descenders, and word lengths, as opposed to just using ‘abc 123 abc 123’, ‘Content here content here’, or the like.”
If you want to use the text, here’s how:

Word 2007:

Word 2007 has a built-in function, similar to rand, that produces this text automatically. Type =lorem() and press Enter. The text entered is not identical to what is given below but is similar.

Word 2003 and earlier:

  1. 1. A sample of “lorem ipsum” text is provided below. Copy it and paste it into a Word document.
  2. You may want to duplicate the text (to expand it) and edit it to create longer or shorter paragraphs, add some dummy headings, or the like. (The chunk I have saved is about a page long, which is a useful size; you can always truncate it as needed.) Needless to say, you can break the text anywhere—not just between sentences.
  3. To keep Word’s spelling checker from going crazy when you use this text, do it (and yourself) a favor by turning off spell checking for this text. To do that, select the text, go to Tools | Language | Set Language, and check the box for “Do not check spelling or grammar.” (In some earlier versions, choose “(no proofing)” as the language.)
  4. To save the text as an AutoText entry, select it, press Alt+F3, and type in a name for your AutoText entry. (After some experimentation, I settled on “lorem”; now whenever I type “lore” and press Enter, the text is inserted.)Here’s the text:
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.
Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio.
Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
One caveat about the above sample: it does not contain every letter in the English alphabet. If it is important for testing purposes that you include every letter, then you are better off with quick brown foxes.