WD2000: DOC-PATH Policy Is Not Enforced When You Save to a Different Folder (311252)
The information in this article applies to:
This article was previously published under Q311252 SYMPTOMS
When you use the Save As dialog box to navigate and save to another location, Microsoft Word overrides the default folder location (DOC-PATH registry key policy).
If you save the document again in the same session, Word uses the location that you navigated to as the default, and not the default DOC-PATH location.
WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
To work around this behavior, you can create macros that replace the built-in Save and Save As commands. You can put these macros in a global template so that they are always available.
To implement this workaround, follow these steps:
- Start Word.
- In a new, blank document, point to Macro on the Tools menu, and then click Visual Basic Editor.
- In the Visual Basic Editor, paste the following code in a new module in your document (not in the Normal.dot template).
NOTE: To make sure that the code is in the correct location, press CTRL+R to switch to the Project Explorer, and then expand your document project, such as Project (Document 1). If the Modules subfolder is not listed, right-click your document project, point to Insert on the shortcut menu, and then click Module. You can now paste the following code in the Code window for the newly created module:
Sub FileSaveAs()
'
' FileSaveAs Macro
' Saves a copy of the document in a separate file.
'
Dim strPath As String
strPath = Application.Options.DefaultFilePath(wdDocumentsPath)
Application.ChangeFileOpenDirectory strPath
Dialogs(wdDialogFileSaveAs).Show
Application.Options.DefaultFilePath(wdDocumentsPath) = strPath
End Sub
Sub FileSave()
'
' FileSave Macro
' Saves the document.
'
Dim strPath As String
strPath = Application.Options.DefaultFilePath(wdDocumentsPath)
' Is this document already saved...
If ActiveDocument.Path = "" Then
' Not already saved then show the SAVE dialog
Application.ChangeFileOpenDirectory strPath
Dialogs(wdDialogFileSaveAs).Show
Else
' Already saved, then just save.
ActiveDocument.Save
End If
Application.Options.DefaultFilePath(wdDocumentsPath) = strPath
End Sub
- Close the Visual Basic Editor.
To make these functions always available, you can save the document as a template, and then reference it as a global template. To do this, follow these steps:
- On the File menu, click Save As.
- Navigate to the location in which you want to save the file. Type a file name, and then click Document Template in the Save as type list. Click Save.
- On the File menu, click Close.
- On the Tools menu, click Templates and Add-ins.
- Click Add.
- Locate and select the template file that you saved in step 2.
- Click OK, and then click OK again to close the Templates and Add-ins dialog box.
Because of the way that the macros are named, the new macros automatically replace the built-in Save and Save As commands.
Modification Type: | Minor | Last Reviewed: | 1/6/2006 |
---|
Keywords: | kbfix kbprb KB311252 |
---|
|