PC Review


Reply
Thread Tools Rate Thread

Automatic Date and time in word document title

 
 
dakke
Guest
Posts: n/a
 
      15th Jan 2008
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?
 
Reply With Quote
 
 
 
 
Doug Robbins - Word MVP
Guest
Posts: n/a
 
      16th Jan 2008
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 File>SaveAs or File>Save 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" <(E-Mail Removed)> wrote in message
news:EF8DEE95-8367-49B6-BFE8-(E-Mail Removed)...
> 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?



 
Reply With Quote
 
dakke
Guest
Posts: n/a
 
      16th Jan 2008
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.
 
Reply With Quote
 
Doug Robbins - Word MVP
Guest
Posts: n/a
 
      16th Jan 2008
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" <(E-Mail Removed)> wrote in message
news:0F9005A1-30E0-4868-8B55-(E-Mail Removed)...
> 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.



 
Reply With Quote
 
dakke
Guest
Posts: n/a
 
      16th Jan 2008
Yes, it works.

Now tweak it a little and done.

Thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Date in Word Document valerie Microsoft Word Document Management 2 26th Nov 2009 06:09 AM
Place the document save date and time in the name of the word docu cdellert Microsoft Word Document Management 3 24th Oct 2008 06:36 AM
I can remove document but not document title in vista word - help Brenda Microsoft Word Document Management 2 4th Jul 2008 07:29 AM
Date and time info not being saved in document versions - Word 200 =?Utf-8?B?TWFydGlu?= Microsoft Word Document Management 2 2nd Oct 2006 06:29 AM
Can I time/date stamp a read-only section of a Word document? =?Utf-8?B?SmFuIFcuLCBDaGljYWdv?= Microsoft Word Document Management 1 29th Oct 2005 04:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:02 PM.