View Single Post
 
Old 03-17-2016, 10:41 AM
JonFleming JonFleming is offline Windows 10 Office 2016
Novice
 
Join Date: Feb 2016
Posts: 15
JonFleming is on a distinguished road
Default Force save after opening a template based file

My boss wants to set up our internal templates so that the user is forced to save the new document immediately upon opening it. In some of them the only VBA will be the save-forcer, in others there are macros that should be preserved. Here's what I have:

Code:
Private Sub Document_New()
    Dim intChoice As Integer
    Dim strPathName As String
            
    intChoice = 0
    While intChoice = 0
        intChoice = Application.FileDialog(msoFileDialogSaveAs).Show
        If intChoice <> 0 Then
            strPathName = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1)
            If Right$(strPathName, 1) = "x" Then
                strPathName = Left$(strPathName, Len(strPathName) - 1) & "m"
            End If
            ActiveDocument.SaveAs2 FileName:=strFileName, FileFormat:=wdFormatXMLDocumentMacroEnabled
        End If
    Wend
End Sub
But this saves as a docx (I don't trust the users to select docm).

Suggestions on how to delete this code after running are welcome.
Reply With Quote