View Single Post
 
Old 03-21-2016, 02:50 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by JonFleming View Post
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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote