Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Opinicus[_2_] Opinicus[_2_] is offline
external usenet poster
 
Posts: 97
Default Save As węth date and time

In the Excel group someone posted a macro for saving an Excel worksheet with
the date and time automatically appended.

Is there a way to do a similar thing in Word? When the macro is run it will
save a copy of the file with the current name (basename) but with the date
and time appended thus for example:

basename yymmdd hhmm

TIA
--
Bob
http://www.kanyak.com

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Save As węth date and time

You need something along the lines of the following, which will save a timed
and dated copy (in the requested format) in the folder defined in
strBackupPath. This must be a valid folder name. If you set strBackupPath =
"" the backup copy will be saved in the current folder. The original
document remains the active document. The macro should work with doc and
docx formats. See also http://www.gmayor.com/automatically_backup.htm

Sub SaveATimedCopy()
Dim strFileA As String
Dim strFileB As String
Dim strFileC As String
Dim strBackupPath As String
strBackupPath = "D:\My Documents\Test\"
With ActiveDocument
.Save
strFileA = .Name

If Right(strFileA, 1) = "x" Then
strFileB = Left(strFileA, Len(strFileA) - 5) & _
Chr(32) & Format(Date, "yyMMdd") & _
Chr(32) & Format(Time, "hhmm") & ".docx"
Else
strFileB = Left(strFileA, Len(strFileA) - 4) & _
Chr(32) & Format(Date, "yyMMdd") & _
Chr(32) & Format(Time, "hhmm") & ".doc"
End If
strFileB = strBackupPath & strFileB
strFileC = .FullName
.SaveAs FileName:=strFileB
.SaveAs FileName:=strFileC
End With
End Sub

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Opinicus wrote:
In the Excel group someone posted a macro for saving an Excel
worksheet with the date and time automatically appended.

Is there a way to do a similar thing in Word? When the macro is run
it will save a copy of the file with the current name (basename) but
with the date and time appended thus for example:

basename yymmdd hhmm

TIA



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Place the document save date and time in the name of the word docu cdellert Microsoft Word Help 3 October 24th 08 06:36 AM
Removing Revision Number and Edit Time, Date Created, Date Last Sa Collected Letters Microsoft Word Help 7 September 11th 08 05:00 PM
Need Save Date - Not Save Date & Time Field Sandra Microsoft Word Help 1 October 4th 07 08:22 PM
paste time and date into save as Fritz New Users 2 June 7th 07 04:17 PM
Format Date and Time to show Military Time AlanFD Microsoft Word Help 2 September 22nd 06 10:44 PM


All times are GMT +1. The time now is 08:55 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"