Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 03-19-2016, 12:10 AM
gmayor's Avatar
gmayor gmayor is offline Force save after opening a template based file Windows 10 Force save after opening a template based file Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Your document also saves as strFilename, which doesn't exist in your code. As Paul indicates the document should be docx format and the code is in the template. The code when edited to
Code:
Option Explicit
Private Sub Document_New()
Dim intChoice As Integer
Dim strPathName As String
    intChoice = Application.FileDialog(msoFileDialogSaveAs).Show
    If intChoice <> 0 Then
        strPathName = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1)
        ActiveDocument.SaveAs2 Filename:=strPathName, FileFormat:=wdFormatXMLDocument
    End If
End Sub
saves as docx and the document can certainly be opened without error.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
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 03:47 AM.


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