P
Peter Noneley
Hi,
Word 2003
I have created a macro to save a file and have a duplicate saved at
the same time.
The duplicate is saved in a different folder, and has the date and
time included as part of the filename.
The code works, but I'm sure it can be improved.
My questions are:
(1) Can I prevent the duplicate from being included in the Most
Recently Used files list?
(2) Are there any other improvements I could make to the code?
Thanks
Peter
---------------------------------------------------------------------------------------
Sub SaveDuplicate()
'This macro saves the current document in two places.
'The original is saved as usual and a duplicate copy is saved to a
different folder.
'The duplicate has the same filename, but with the Date and Time
included in the filename.
'For example, for a file named "MEMO", the duplicate would be "MEMO
2010-01-01 09-54-28.doc"
Dim strDuplicateTime As String
Dim strDuplicatePath As String
Dim strDuplicateName As String
Dim strOriginalName As String
'Remember the original File name and Path of the doc to be saved.
strOriginalName = ActiveDocument.FullName
'Get the current Date and Time. These will form part of the duplicate
file name.
strDuplicateTime = Format(Now, " yyyy-mm-dd hh-mm-ss")
'This is the folder I will be using to save my duplicates.
strDuplicatePath = "C:\MyDuplicates\"
'This picks out just the Filename, without the Path or Extension.
strDuplicateName = Left(ActiveDocument.Name, Len(ActiveDocument.Name)
- 4)
'Save the Duplicate file.
ActiveDocument.SaveAs FileName:=strDuplicatePath & strDuplicateName &
strDuplicateTime
'Save the original file.
ActiveDocument.SaveAs FileName:=strOriginalName
End Sub
---------------------------------------------------------------------------------------
Word 2003
I have created a macro to save a file and have a duplicate saved at
the same time.
The duplicate is saved in a different folder, and has the date and
time included as part of the filename.
The code works, but I'm sure it can be improved.
My questions are:
(1) Can I prevent the duplicate from being included in the Most
Recently Used files list?
(2) Are there any other improvements I could make to the code?
Thanks
Peter
---------------------------------------------------------------------------------------
Sub SaveDuplicate()
'This macro saves the current document in two places.
'The original is saved as usual and a duplicate copy is saved to a
different folder.
'The duplicate has the same filename, but with the Date and Time
included in the filename.
'For example, for a file named "MEMO", the duplicate would be "MEMO
2010-01-01 09-54-28.doc"
Dim strDuplicateTime As String
Dim strDuplicatePath As String
Dim strDuplicateName As String
Dim strOriginalName As String
'Remember the original File name and Path of the doc to be saved.
strOriginalName = ActiveDocument.FullName
'Get the current Date and Time. These will form part of the duplicate
file name.
strDuplicateTime = Format(Now, " yyyy-mm-dd hh-mm-ss")
'This is the folder I will be using to save my duplicates.
strDuplicatePath = "C:\MyDuplicates\"
'This picks out just the Filename, without the Path or Extension.
strDuplicateName = Left(ActiveDocument.Name, Len(ActiveDocument.Name)
- 4)
'Save the Duplicate file.
ActiveDocument.SaveAs FileName:=strDuplicatePath & strDuplicateName &
strDuplicateTime
'Save the original file.
ActiveDocument.SaveAs FileName:=strOriginalName
End Sub
---------------------------------------------------------------------------------------