Creating a Lorem Ipsum Tool

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


1

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 lorem 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.)

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 (13484) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, Word in Microsoft 365, and 2021.

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

Making Changes in a Group of Workbooks

If you need to change the same data in a large number of workbooks, the task can be daunting. Here are some ideas (and ...

Discover More

Jumping to a Relative Line Number

As you navigate through a document, you may have a need to move forward or backward a specific number of lines. This is ...

Discover More

Linking Word Documents

Want to add one document to another document? You can do it by adding links, described in this tip.

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)

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

Creating Multiple Highlighter Tools

Some people, while developing documents, like to use the Highlighter tool quite a bit. It can quickly get monotonous, ...

Discover More

Ignoring Hyphens in Word Counts

When you instruct Word to tell you how many words are in a document, it treats hyphenated words or phrases as if they are ...

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 2 + 2?

2023-12-04 09:51:12

Andrew

Here's how I do it:

Sub Lorem()
Selection.Text = Replace("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue " & _
"massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna " & _
"eros quis urna.#Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus.#Pellentesque habitant morbi " & _
"tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.#" & _
"Aenean nec lorem. In porttitor. Donec laoreet nonummy augue.#Suspendisse dui purus, scelerisque at, vulputate " & _
"vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.#", "#", vbCr)
Selection.NoProofing = True
Selection.Collapse wdCollapseEnd
End Sub


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.