Re: Saving document with new name via vba by Tony
Tony
Tue Jun 26 22:57:14 CDT 2007
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.