![]() |
|
#2
|
||||
|
||||
|
Quote:
This code should get you most of the way there. Code:
Sub SaveMeYeezy()
Dim sName As String, aCC As ContentControl, iSpacePos As Integer
Dim sFilename As String, sNow As String, sPath As String
sPath = "C:\Users\username\Desktop\"
Set aCC = ActiveDocument.ContentControls(1)
sName = Trim(aCC.Range.Text)
iSpacePos = InStr(sName, " ")
If iSpacePos > 0 Then
sName = Mid(sName, iSpacePos) & "," & Left(sName, iSpacePos)
sName = Replace(sName, " ", "")
End If
sNow = Format(Now, "dd-mm-yy_HHMMSS")
sFilename = sName & "_" & sNow & ".docm"
ActiveDocument.SaveAs2 FileName:=sPath & sFilename, FileFormat:=wdFormatXMLDocumentMacroEnabled
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to save Word file by field name as filename using VBA button? | TribeBuckeyeFan | Word VBA | 4 | 02-02-2017 05:58 AM |
How to save Word file by field name as filename using VBA button?
|
chemtoli | Word VBA | 5 | 01-25-2017 08:06 AM |
| Save and rename attachments from ZIP FILE | AndyDDUK | Outlook | 1 | 03-03-2016 12:32 AM |
Have to rename file every time to save workbook
|
intelli | Excel | 3 | 03-27-2014 11:53 PM |
Rename Document & Save
|
d4okeefe | Word VBA | 4 | 05-23-2013 09:35 AM |