Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Creating a New Document in VBA.

Creating a New Document in VBA

by Allen Wyatt
(last updated November 16, 2013)

2

One of the common things done during a macro is to create a new document. For instance, your macro could need the new document to hold processed text, or a different version of the document on which you are working.

To create a new document, simply include this line in your VBA macro:

Documents.Add

This creates a new document, based on Normal.Dot, adds it to the Documents collection, and makes the document active. This is the same as clicking the New button on the toolbar. If you want to create a new document based on a different template, simply use this command:

Documents.Add("MyTemplate.dot")

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12725) applies to Microsoft Word 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Word here: Creating a New Document in VBA.

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

Line Numbering and Tables

Some types of documents (such as legal documents) may require that individual lines of text be numbered. If you use ...

Discover More

Deriving High and Low Non-Zero Values

When analyzing your numeric data, you may need to figure out the largest and smallest numbers in a set of values. If you ...

Discover More

Sorting Letters and Numbers

Sorting information in a worksheet can be confusing when Excel applies sorting rules of which you are unaware. This 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)

Locating the My Documents Folder

Need to do some macro processing of documents in the user's My Documents folder? First step is to figure out where the ...

Discover More

Deleting a Macro

ScreenTips can appear with or without shortcut keys displayed in them. Here's how to control whether they appear or not.

Discover More

Assigning a Macro to a Shortcut Key

Do you have a macro that you use frequently? Using the file menu to access the macro can be time consuming. This tip ...

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 minus 0?

2015-06-04 14:09:58

Marcel Marien

I would find it helpful to find on the Document.Add page a hint about how to address a newly added document. Not every time the document name "Document1" will be assigned.


2014-10-14 19:07:10

Ryan G

Hi,
I have been trying to figure out how to do something and thought you might know.
I am trying to create a new document from a template within another Word Document.
If I call Word.Documents.Add template:="C:TemplatesTest.dotm", the new document opens based on that template but the calling document is locked until that new document is closed.
If I can Word.Documents.Open filename="C:Templatestest.dotm", it opens in its own window and the original document is able to be edited.
I need to be able to create a new document based on a template from within a template without adding it to the Documents collection. Is this possible in VBA? Any suggestions are appreciated.


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.