PDA

View Full Version : Macro to ad a suffix to document title



Jack Rabbid
05-20-2014, 04:44 AM
Hi,

I've recently begun to realise just how enormously useful macros can be, especially in my work as a translator/revisor. I've managed to make a few very simple ones for specific tasks, but mostly just using "record macro".

What I'm currently looking for is a macro that, when activated:

1) Turns on "track changes" if it is off (and preferably sets the display to "no markup", but that's optional)
2) Saves a copy of the active document in the same directory as the active document, but with "_TC" added to the end of the document name.

That's all. It would actually make my job a bunch easier, but this is a code-writing job and I'm afraid that's a skill that I don't quite have. Yet, I hope.

I'd be grateful for any help! :D

macropod
05-20-2014, 07:47 PM
Try something based on:

Sub MakeTC()
Application.ScreenUpdating = False
Dim StrName As String, StrExt As String, lFmt As Long
With ActiveDocument
.TrackRevisions = True
.ShowRevisions = True
With .ActiveWindow.View
.ShowRevisionsAndComments = False
.RevisionsView = wdRevisionsViewFinal
End With
StrName = .FullName: lFmt = .SaveFormat
StrExt = "." & Split(.Name, ".")(UBound(Split(.Name, ".")))
StrName = Left(StrName, Len(StrName) - Len(StrExt))
.SaveAs2 FileName:=StrName & "_TC" & StrExt, _
Fileformat:=lFmt, AddToRecentFiles:=False
End With
Application.ScreenUpdating = True
End Sub

Jack Rabbid
05-22-2014, 12:21 AM
That's perfect! Thanks loads :D