Quote:
Originally Posted by macropod
You could add code like the following to each template's 'ThisDocument' module. As coded, it prompts the user to save the file immediately it's created and defaults to whatever path is specified for the StrTmpPath variable and with whatever filename's specified for the StrName variable (which i've coded for the user's name and the system date in ISO format.
Code:
Private Sub Document_New()
Dim StrName As String, StrDefPath As String, StrTmpPath As String
StrName = Environ("UserName") & Format(Now, "YYYYMMDD")
StrTmpPath = "Filepath for documents based on this template"
StrDefPath = Options.DefaultFilePath(wdDocumentsPath)
Options.DefaultFilePath(wdDocumentsPath) = StrTmpPath
With Application.Dialogs(wdDialogFileSaveAs)
.Name = StrName
.Show
End With
Options.DefaultFilePath(wdDocumentsPath) = StrDefPath
End Sub
|
Hey Paul,
This code works wonders form me great job. I have one request though. Is it at all possible to change the code at the strname variable from the user of the system to a string in the actual document. I'm creating a form for my employees to enter clients information and have created a field for the customer name that I want the code to use as the name of the file. If it helps at all I have mapped the customer name to an xml node that i use for filling other fields throughout the document.
Thanks,
Zach Jennings