Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 03-21-2016, 02:50 PM
macropod's Avatar
macropod macropod is offline Force save after opening a template based file Windows 7 64bit Force save after opening a template based file Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,513
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Force save after opening a template based file How to Force a "Save As" for a fillable form cbalogh Word 6 01-27-2014 05:50 PM
Force save after opening a template based file save as filtered HTML – force graphics format to .png eNGiNe Word 2 01-23-2014 06:27 AM
Force save after opening a template based file Force User to Save As lgillespie Word 6 09-09-2013 03:13 PM
Force save after opening a template based file VBA Code to force 'Save As' rossi45 Excel Programming 1 05-11-2012 03:05 PM
Template "File In Use" when opening 2 documents based on the same template wendt Word 5 12-15-2009 12:37 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:47 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft