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

Inserting a File Name without an Extension

Sometimes you might like to insert a file name into your document without including the file extension. The FILENAME field ...

Discover More

Sorting Data Containing Merged Cells

When formatting the layout of your worksheet, Excel allows you to easily merge adjacent cells together. This can cause havoc ...

Discover More

Easily Changing Links in Documents

You may have a lot of linked images in a document, and then one day need to change the links if the location of the images ...

Discover More

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!

More WordTips (ribbon)

Word Count in Multiple Selections

Getting a word count for an entire document is easy. What you may not know is that some versions of Word can also provide ...

Discover More

Understanding Master and Subdocuments

Most people use Word to create regular documents that you edit, view, and print. The program also allows you to create a ...

Discover More

Finding Related Words

One part of the grammar tools provided with Word is a thesaurus that helps you find all sorts of word variations. One type 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}] 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 four less than 4?

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.