Creating a Lorem Ipsum Tool

by Allen Wyatt
(last updated October 22, 2016)

10

Charles created a macro to insert lorem ipsum text in a document. He turned on the macro recorder, typed =lorem(), and then pressed Enter. This, of course, inserted the loreem ipsum text. He placed a shortcut to the macro on the Quick Access Toolbar, but the recorded macro only partially works. It types =lorem() for him, but he still needs to manually press Enter. Charles has tried to edit the macro to have it include the Enter command so that when he clicks on the macro shortcut the text gets entered, but to no avail.

If you want your macro to simulate pressing Enter, then you'll need to use the SendKeys command. Chances are good that when you recorded your macro, it looks very similar to this:

Sub Macro1()
'
' Macro1 Macro
'
'
    Selection.TypeText Text:="=lorem()"
    Selection.TypeParagraph
End Sub

What you need to do is to replace the last line of the macro (the one just before End Sub) to either of the following:

    SendKeys "~", True
    SendKeys "{ENTER}", False

Either of these lines (you only need one of them) will simulate pressing Enter. There is one gotcha to be aware of, however—SendKeys works in whatever window is currently active. This means you cannot run the macro from within the Visual Basic Editor and get the desired effect. The reason is because when you do that, it is the window in the Editor that is active, so SendKeys "presses Enter" within that window. You should only run the macro when your Word document window is active.

That being said, there is another way you could approach the macro, without using the SendKeys command. All you need to do is to create a new Word document that contains your lorem ipsum text, followed by whatever you want. Name this something unique, such as LoremText.docx. Then, create a macro like this one:

Sub Lorem()
    Selection.InsertFile FileName:="C:\Users\User\Desktop\LoremText.docx"
End Sub

You just need to make sure that the path and filename shown in the macro represents the actual path and filename appropriate for your system. When you run the macro, Word goes out and grabs the LoremText.docx document and inserts it at the insertion point.

Finally, there is another way you could approach this issue without the need of resorting to macros. You could, if desired, insert the lorem ipsum text into your document, select it, and save it as a Building Block or as an AutoCorrect entry. You can then easily insert the text—modified in whatever way you desire—using these Word tools. (How to create and use both Building Blocks and AutoCorrect entries has been covered in other WordTips.)

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13484) applies to Microsoft Word 2007, 2010, 2013, and 2016.

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

Displaying a Single Page

When displaying the information in your document, Word is rather flexible. It can, if you so choose, display multiple ...

Discover More

Formatting Text Files with VBA

Got a bunch of text that you've imported from a text file? Need to make it look better? You can take a stab at it with this ...

Discover More

Pulling Filenames into a Worksheet

You can use Excel for all types of data processing. You may want to work with filenames in a worksheet, but the first task is ...

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)

Word Counts for a Group of Documents

Getting a word count for a single document is easy. Getting an aggregate word count for a large number of documents can be a ...

Discover More

Translating Text

Word 2010 includes several different tools you can use to improve your writing. One such tool (new to Word 2010) is the ...

Discover More

Moving Master and Subdocuments

If you need to move master documents or subdocuments from one place to another on your computer, you have to keep in mind the ...

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. 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 7 - 2?

2016-10-25 07:48:41

Ken Endacott

Steve. Many organisations control options in the copy of Word loaded onto workstations so that Macro Settings is not available.

Jenifer. You will win the bet every time because =rand(), =lorem() and =rand.old() generate text that has settings to inhibit spell checking. Try copying part (not whole paragraphs) of the Latin text to elsewhere in the document and spelling errors will be shown. That is unless you have a Latin dictionary loaded.


2016-10-24 10:49:34

Amy

Could you skip the whole =rand or =lorem process by adding a "word" to your custom dictionary that swaps in the (lorem) text you want? That would avoid the need to mouse to the icon, and avoid the macro security.


2016-10-24 09:28:31

Steve

Paul, I agree with Allen... restricting the use of macros all together only reduces productivity. It is true that people can create harmful macros and can be saved to a document when passed to others via email, etc., but you may have some options. First, its possible that your company simply disables macros by default, which means that you may be able to simple alter the settings for your local copy of Word. Try going to File, then Options, Trust Center, Trust Center Settings, Macro Settings. See how its currently set and if there is a suitable option for you, such as "Disable all macros with notification", or "Disable all macros except digitally signed macros".


2016-10-24 09:11:55

Jennifer Thomas

Use =rand(x,y) for English or =lorem(x,y) for pseudo-Latin.

I particularly like adding the y value of '1' for demonstrating formatting options on sample title or list paragraphs, but that works better with lorem than with rand.

Just a thought for those pondering how to use this tool (other than to win a bet that you can create 5 pages of correctly-spelled text in less than a minute, which earned me 20 reluctantly-given bucks one time - geek-fun at its finest!).


2016-10-24 08:46:08

allen@sharonparq.com

Paul: That's pretty strict! Using macros is what can make any Office application *MUCH* more productive for individual office needs. Prohibiting them actually hobbles what employees can do for the company.

-Allen


2016-10-24 06:16:38

Paul Franklin Stregevsky

Art,
Everywhere I've worked for the past 15 years, MS Office macros have been prohibited.


2016-10-23 15:09:24

Art Osgatharp

Paul -

Create a macro as described in the article, then add an icon for the macro to your Quick Access toolbar (More Commands...Choose commands from: Macros. Select your macro and click Add).


2016-10-23 06:30:43

Paul Franklin Stregevsky

I can't find a command or shortcut for this feature that I can hang on my Quick Access Toolbar. Anyone?


2016-10-22 21:38:57

Geof Richardson

Hi
More on =rand(x)

=rand(x,y)
x= number of paragraphs
y = number sentences per paragraph

Regards
Geof


2016-10-22 18:41:38

Art Osgatharp

Another way to insert random text is the rand command: =rand(number of paragraphs desired). Typing =rand(10) and pressing Enter will insert 10 paragraphs of readable random text. This can be used in a macro in the same way as the =lorem command.


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.

Newest Tips
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.