On Jun 27, 7:33 am, rach...@gmail.com wrote:
> To restate what I would like help with is that I want a macro which
> will add "_locked".doc at the end of the current name of the document
> and save it as a new file.
>
> Thanks
Hi Rach,
Try this.
Dim strNewName As String
Dim dt As Single 'Location of the dot before the filename
extension
strNewName = ActiveDocument.FullName
dt = InStrRev(strNewName, ".")
strNewName = Left(strNewName, dt - 1) & "_Locked" &
Mid(strNewName, dt)
ActiveDocument.SaveAs FileName:=strNewName
This will keep save the document to the same folder and preserve the
extension.
Of course this new doc now becomes the activedociument so if you then
want to go back/work on the original document you have to close this
new one and open the original.
Cheers
TonyS.
rachitm@gmail.com - 27 Jun 2007 20:43 GMT
Thanks Tony , this works perfect!
Got a question, is there a way that the original document can still be
open after it saves it with the new document name.....?
Russ - 30 Jun 2007 01:16 GMT
Rachitm,
> Thanks Tony , this works perfect!
>
> Got a question, is there a way that the original document can still be
> open after it saves it with the new document name.....?
A simple modification of Tony's routine should do want you want.
The original, unmodified document is reopened.
Dim strOriginalName As String
Dim strNewName As String
Dim dt As Single
strOriginalName = ActiveDocument.FullName
strNewName = ActiveDocument.FullName
dt = InStrRev(strNewName, ".")
strNewName = Left(strNewName, dt - 1) & "_Locked" & _
Mid(strNewName, dt)
ActiveDocument.SaveAs FileName:=strNewName
'ActiveDocument.Close
Documents.Open FileName:=strOriginalName
UnComment the .Close line, if that is what you want.

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID