View Single Post
 
Old 05-13-2014, 10:51 AM
Charles Kenyon Charles Kenyon is offline Windows 7 64bit Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,533
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

OK.

Then your new document is formed when the user double-clicks on the template or uses one of the File New Variations to create a new file. The user does NOT open the template.

You can use your UserForm's OK click event to open the File Save As dialog with your proposed name or simply save the document with the name you want. Simply use the variable information you already have to create your filename string

Here is code that I use in one of my forms to insert the current date as a part of the name.

Code:
Private Sub SaveAsLetter()
    ' Run as part of first step - saves letters using preferred format for name
    Dim strName As String, dlgSave As Dialog
    Set dlgSave = Dialogs(wdDialogFileSaveAs)
    strName = "Letter " & Format((Year(Now() + 1) Mod 100), "20##") & "-" & _
        Format((Month(Now() + 1) Mod 100), "0#") & "-" & _
        Format((Day(Now()) Mod 100), "0#")
    ActiveDocument.BuiltInDocumentProperties("Title").Value = strName
    With dlgSave
        .Name = strName
        .Show
        
    End With
End Sub
I believe if instead of .Show it was .Execute, it would simply save without user input unless there was already a file with that name.

You would use the ChangeFileOpenDirectory method to change to the folder you want to use.
Reply With Quote