Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Is there a way to include the date and time in the title of the document in
that way that each time you save the document the data and time are updated and as such stored as a brandnew file? eg: Document title: Test 11-1-2008 11:12 pm.doc Modify and work on another day making it: Test 13-1-2008 08:32 pm.doc All without manually updating the file name? |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Create a macro called FileSave()
Dim fname as String fname = InputBox("Enter the filename", "File Save As") With ActiveDocument .Variables("varfname").Value = fname .SaveAs fname & Format(Now(), "dd-M-yyyy hh:mm AMPM") End With and for the subsequent saves a macro called FileSaveAs() With ActiveDocument .SaveAs .Variables("varfname").Value & Format(Now(), "dd-M-yyyy hh:mm AMPM") End With If you put these macros in a Global template, they corresponding one will run whenever you use the FileSaveAs or FileSave command. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dakke" wrote in message ... Is there a way to include the date and time in the title of the document in that way that each time you save the document the data and time are updated and as such stored as a brandnew file? eg: Document title: Test 11-1-2008 11:12 pm.doc Modify and work on another day making it: Test 13-1-2008 08:32 pm.doc All without manually updating the file name? |
#3
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Thanks for the reply.
I'm not familar with macro's, but this is the error I got: Run-time error '5152'; This is not a valied file name. Try on of the following: * Check the path to make sure it was typed correctly. * Select a file from the list of files and folders. (test16-1-2008 02:47 PM) Here's the macro I created based on your advice: Sub Filesave() Dim fname As String fname = InputBox("Enter the filename", "File Save As") With ActiveDocument ..Variables("varfname").Value = fname ..SaveAs fname & Format(Now(), "dd-M-yyyy hh:mm AMPM") End With End Sub Sub FilesaveAs() End Sub With ActiveDocument .SaveAs .Variables("varfname").Value & Format(Now(), "dd-M-yyyy hh:mm AMPM ") End With End Sub So I think it kinda does a thing that comes close, but... It also pops up a window asking to 'Enter the filename', which it shouldnt do ideally since it should take the 'actual' filename and simply update the date and time. Should have been more clear on this. However, entering the filename does not work: 'test', 'test.doc' doesn't do a thing. Is there a way to do this (might be useful to create a field with the title like 'test' and that the macro grabs the field and adds the data and time) Your help is much appreciated, but also points out that I really need to learn more about the macro's. |
#4
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Oops, the colon is causing the problem. Replace it in the Format() function
with something else that suits your fancy. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dakke" wrote in message ... Thanks for the reply. I'm not familar with macro's, but this is the error I got: Run-time error '5152'; This is not a valied file name. Try on of the following: * Check the path to make sure it was typed correctly. * Select a file from the list of files and folders. (test16-1-2008 02:47 PM) Here's the macro I created based on your advice: Sub Filesave() Dim fname As String fname = InputBox("Enter the filename", "File Save As") With ActiveDocument .Variables("varfname").Value = fname .SaveAs fname & Format(Now(), "dd-M-yyyy hh:mm AMPM") End With End Sub Sub FilesaveAs() End Sub With ActiveDocument .SaveAs .Variables("varfname").Value & Format(Now(), "dd-M-yyyy hh:mm AMPM ") End With End Sub So I think it kinda does a thing that comes close, but... It also pops up a window asking to 'Enter the filename', which it shouldnt do ideally since it should take the 'actual' filename and simply update the date and time. Should have been more clear on this. However, entering the filename does not work: 'test', 'test.doc' doesn't do a thing. Is there a way to do this (might be useful to create a field with the title like 'test' and that the macro grabs the field and adds the data and time) Your help is much appreciated, but also points out that I really need to learn more about the macro's. |
#5
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Yes, it works.
Now tweak it a little and done. Thanks |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Disable automatic date/time update | Microsoft Word Help | |||
Date and time info not being saved in document versions - Word 200 | Microsoft Word Help | |||
can current date be automatic on document template when loaded? | Microsoft Word Help | |||
date/time automatic update is off but date still updates. | Microsoft Word Help | |||
Can I time/date stamp a read-only section of a Word document? | Microsoft Word Help |