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

Loading Unwanted Files at Startup

Imagine how painful it would be if every time you started Excel it tried to load all the files in your root directory? That ...

Discover More

Entering or Importing Times without Colons

Enter a time into a cell and you normally include a colon between the hours and minutes. If you want to skip that pesky ...

Discover More

Selecting Text in Linked Text Boxes

Text boxes are often used as design elements in a document layout. If you have linked text boxes, you may have noticed that ...

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)

Detecting an Open Dialog Box

Macros can be used to perform all sorts of tasks within Word. Some tasks can even occur at whatever time interval you desire. ...

Discover More

Converting Numbers to Text

Got some numbers you need spelled out? Here's a handy macro that can convert numbers like "123" to words like "one hundred ...

Discover More

Passing Parameters to Functions

Functions can be used to perform repetitive tasks and return values to your main program. You can also pass values to a ...

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

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.