Word

Starting Word with template of your choice

Ease of Use

Easy

Version tested with

2002 

Submitted by:

fumei

Description:

Simple code to force Word to make its opening document based on a specified template, rather than normal.dot. 

Discussion:

When Word is loaded it creates a blank document with the contents of Normal.dot. This code gives the user the choice to make the opening document use a diffeent template than normal.dot. It uses AutoExec to get a user response, and depending on that response either proceeds to make the regular blank document (based on normal.dot), or a new document based on a specified template. If the user does choose to have a document based on your template file, that file REPLACES the normal blank document. In other words, IT is Document1. You could easily make a UserForm with a dropdown box listing what templates are available. You could also easily adjust this so Word never makes a blank document from normal.dot. NOTE: this code fires when Word itself is first loaded, using AutoExec. To make similar code for the New button, use Document_New. It is important to note that the code must be put into normal.dot itself. 

Code:

instructions for use

			

Option Explicit Sub AutoExec() Dim response response = MsgBox("Are you working on the Variable Project?", vbYesNo) If response = vbYes Then Documents.Add _ Template:="C:\Documents and Settings\Gerry\Application Data\Microsoft\Templates\my_variable.dot" End If End Sub

How to use:

  1. 1. Find and open Normal.dot
  2. 2. Open the VBE (Alt-F11)
  3. 3. Copy the code into a code module of Normal.dot. ThisDocument is fine, or any other existing standard module.
  4. 4. Change the path and filename to whatever template file you want
  5. 5. Save the file (normal.dot)
  6. 6. Quit Word
 

Test the code:

  1. 1. Start up Word
 

Sample File:

No Attachment 

Approved by Jacob Hilderbrand


This entry has been viewed 166 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express