Quote:
"102036" is the current time the file is saved which represents 10:20:36PM
|
This is not good practice. If you ignore the am/pm part then there are two possible times a day. You should either use the 24hr clock or include am/pm info.
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