Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-13-2014, 02:09 AM
rosscortb rosscortb is offline Save As Macro that changes the file name also Windows XP Save As Macro that changes the file name also Office 2010 32bit
Novice
Save As Macro that changes the file name also
 
Join Date: May 2014
Posts: 17
rosscortb is on a distinguished road
Default Save As Macro that changes the file name also

Hello,

I have a template letter document with a userform that insert text at the correct bookmarks.

I have recorded a macro that saves the file to a specific folder( easy enough) but I, if possible, I would like to include some code that changes the name of the file when I run the macro. For example, LastName,FirstName Contract

Someone has give me this but it doesn't seem to like the ME.

If should maybe point out that in the form I am using a txt called txtEmployeeName ( not sure if this is relevant)

Any input would be welcomed.

Thanks

Ross



Sub SaveAS()
'
' SaveAS Macro
'




Dim NewFileName As String
Dim NewFilePath As String


NewFilePath = "H:\HR\Reward & Shared Services\Shared Services Only\1 ~ Starters\3 ~ Contract Templates\DB Templates\"
NewFileName = Me.txtLastName & "," & Me.txtFirstName & ",Contract.docm"


'
ChangeFileOpenDirectory _
"H:\HR\Reward & Shared Services\Shared Services Only\1 ~ Starters\3 ~ Contract Templates\DB Templates\"
ActiveDocument.SaveAs2 FileName:= _
"H:\HR\Reward & Shared Services\Shared Services Only\1 ~ Starters\3 ~ Contract Templates\DB Templates\A-D contract v10-MACRO.docm" _
, FileFormat:=wdFormatXMLDocumentMacroEnabled, LockComments:=False, _
Password:="", AddToRecentFiles:=True, WritePassword:="", _
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, CompatibilityMode:=14
End Sub
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 11:14 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