Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 05-13-2014, 10:51 AM
Charles Kenyon Charles Kenyon is online now Save As Macro that changes the file name also Windows 7 64bit Save As Macro that changes the file name also Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,584
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

OK.

Then your new document is formed when the user double-clicks on the template or uses one of the File New Variations to create a new file. The user does NOT open the template.

You can use your UserForm's OK click event to open the File Save As dialog with your proposed name or simply save the document with the name you want. Simply use the variable information you already have to create your filename string

Here is code that I use in one of my forms to insert the current date as a part of the name.

Code:
Private Sub SaveAsLetter()
    ' Run as part of first step - saves letters using preferred format for name
    Dim strName As String, dlgSave As Dialog
    Set dlgSave = Dialogs(wdDialogFileSaveAs)
    strName = "Letter " & Format((Year(Now() + 1) Mod 100), "20##") & "-" & _
        Format((Month(Now() + 1) Mod 100), "0#") & "-" & _
        Format((Day(Now()) Mod 100), "0#")
    ActiveDocument.BuiltInDocumentProperties("Title").Value = strName
    With dlgSave
        .Name = strName
        .Show
        
    End With
End Sub
I believe if instead of .Show it was .Execute, it would simply save without user input unless there was already a file with that name.

You would use the ChangeFileOpenDirectory method to change to the folder you want to use.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I save a Word file with a macro for distribution? leemoreau Word VBA 3 10-04-2013 08:06 AM
Save As Macro that changes the file name also Macro to create new word doc and save the file using String found in the document VBNation Word VBA 2 02-08-2013 07:14 AM
Save As Macro that changes the file name also A newbie question: a must to save macro word file as .docm? tinfanide Word VBA 6 12-06-2011 03:02 PM
Save As Macro that changes the file name also Word Macro: Save file as text with current file name jabberwocky12 Word VBA 2 10-22-2010 12:23 PM
Macro will not save to normal.dot file when exiting bobbraun Word 1 09-28-2010 06:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:25 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