View Single Post
 
Old 03-23-2016, 08:45 AM
JonFleming JonFleming is offline Windows 10 Office 2016
Novice
 
Join Date: Feb 2016
Posts: 15
JonFleming is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
The problem is entirely of your own making, because you're getting the filename with one variable, then saving it with another, empty, one. Try:
Code:
Private Sub Document_New()
Dim i As Long, strFileName As String
While i = 0
  i = Application.FileDialog(msoFileDialogSaveAs).Show
  If i <> 0 Then
    strFileName = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1)
    strFileName = Split(strFileName, ".doc")(0) & ".docm"
    ActiveDocument.SaveAs2 FileName:=strFileName, FileFormat:=wdFormatXMLDocumentMacroEnabled
  End If
Wend
End Sub
Why you think saving as a docm file is important is unclear. A docx file has access to all the macros in its template (while the template remains accessible), exactly as a docm file does. Conversely, merely saving a file in the docm format doesn't add the template's macros to it.
Your code does exactly what I want it to do. Thank you.
Reply With Quote