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

Creating a Shortcut for Pasting Values

Excel's Paste Special command is used quite a bit. If you want to create some shortcuts for the command, here's some ways ...

Discover More

Counting the Times a Worksheet is Used

Do you need to know how many times a worksheet has been used? Excel doesn't track that information, but you can develop ...

Discover More

Shortcuts for Basic Style Formatting

Want to get your text away from the explicit formatting you applied, back to the underlying formatting? Here are a few ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Comparing Document Versions

Do you need to compare two versions of a document to each other? Word provides a tool that can make this easy, as ...

Discover More

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

Word Count for a Section

Dynamic word counts for your entire document are easy to get when you use using fields. There is no built-in method to ...

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 - 5?

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.