Dragon Drop - A Visual Basic Software Consultancy

Word Code

Folders: Document folders, Template folders and Start-up folders

In Word there are are three folders which one should be concerned about. These should be set up when Word is installed and then these ought to remain in place.

Documents Path

The first one is the Documents Path. This, quite simply, is where Word expects to find the documents that you have created and where it will attempt to save them. By default these are placed in your My Documents folder in your User Library unless you set this to be somewhere different.

Here, for example, is the default Word settings for my machine running Word 2007, which is my preferred version of Word.

One can find this dialog by clicking on the big round Office button (top left of Word) and then clicking on the Word Options button at the botton of the dialog box. The Options dialog then pops up, click on the Advanced button (left hand side) and scroll all the way down to File Locations.

This Documents folder is the most obvious and the easiest to understand. I have personally chosen to not to have this set to point to the User Libraries for a number of reasons. Mostly because I want everything to be outside of the User Libaries and into my own file structure because of my back-up processes and I prefer not to have anything within the User Libraries. However, this will be down the personal preference or down to the rules of the IT department of the firm in which one is working.

The important thing is that this folder is where you can expect to find your Word documents.

Document Templates Folder

Each document type is created on a template. In an ideal world a letter should be written using a letter template suited for one's needs and purposes. The document templates such as Letter.dotx or Memo.dotx (for a letter and a memo, respectively) will be living in this folder.

The advantage of having a folder for templates not being in a User Library is that if one is in a small firm then it's easy to share templates. When a user starts up the machine each day then, for example, a small script could run which could copy all of the templates from a central server to this location.

This means that one can have one central store of templates and have them available to each user on their machines when they need them.

And if one isn't in a networked environment like this it's easy to write a back-up script to make sure that any templates which are developed are backed up safely.

Start-up Templates Folder

On this site there are a number of templates that I have created which are meant to be placed into the Start-up folder. This is that folder.

These templates that go in there aren't templates as we would normally consider them to be. These templates aren't designed to have any documents created from them but are simply a storage area for code.

When one installs Word straight out of the box it has a number of tools and utilities which one can find in the menu (or, these days the Ribbon Bar) but by placing code within a template that lives in the Start-up folder one can expand upon the range of functions with one's own.

The Find & Replace template, for example, would be placed in the Start-up folder and then, the next time that Word starts up (hence the name) the functions within are then available to the user.

Personal Preferences

I have changed the File Locations dialog box to suit my personal preferences which are shown after the code snippet below.

Code

This article wouldn't be complete without some code. Copy, paste and run this routine and it will display the three folder paths.


Public Sub DisplayFilePaths()

  Dim sMessage As String
  
  sMessage = "Default File Path: " & Options.DefaultFilePath(wdDocumentsPath) & vbCrLf & _
              "Document Template Folder: " & Options.DefaultFilePath(wdUserTemplatesPath) & vbCrLf & _
              "Word Startup Folder: " & Options.DefaultFilePath(wdStartupPath)
  
  MsgBox sMessage

End Sub

The above code, running on my machine, gives the following.

Updates or Comments

If there are any suggestions for updates or comments then please drop us a mail at malcolm.smith@dragondrop.com.