Quote:
Originally Posted by JonFleming
Oh, and the error message tells me that Word can't open the file and cannot produce a reason why. Useless.
|
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.