Date

  • Thread starter Thread starter Tonya Marshall
  • Start date Start date
T

Tonya Marshall

I see what you are saying. You may want to go to the VBA group and ask
your question there.

news://msnews.microsoft.com:119/microsoft.public.word.vba.beginners

Tonya Marshall
 
I have Word 2000. Can someone please tell the shortest, simplest way to
insert the current date in a document? Not a date that changes every time I
open or print, just the date that I insert. In the format I want, not that
I want to have to go in and choose the format every time. I cannot find a
simple way to do it. The best I can find seems to be about 8 or 9
keystrokes long and that's just ridiculous in this age of carpal tunnel
syndrome... In Word Perfect, I can do it with control-d.
 
The following macro will insert a non-updating date in the document. The
format is November 25, 2003. There are other configurations if you
prefer 11/25/03, etc. You can put a button on a toolbar to insert the date:

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"CREATEDATE \@ ""MMMM d, yyyy"" ", PreserveFormatting:=True


Go here to find out what to do with the macro
http://www.mvps.org/word/FAQs/MacrosVBA/CreateAMacro.htm
 
I went to the site you gave me and followed the instructions but nothng
happens. I copy/pasted and when I try to run the macro nothing happens at
all. The cursor just sits there and blinks.
 
I wonder if it might have wrapped in here. In the first line there is a
space after Text:= then an underline. Press the Enter key after the
underline for the second line

My macro looks like this

Sub InsertDate()
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"CREATEDATE \@ ""MMMM d, yyyy"" ", PreserveFormatting:=True
End Sub

Tonya Marshall
 
This is exactly what I have: (copy/paste)

Sub insertdate()
'
' Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"CREATEDATE \@ ""MMMM d, yyyy"" ", PreserveFormatting:=True


End Sub

The spaces are where you said they should be. I run it and nothing happens
at all.
 
That ' next to selection turns it into a comment and it won't run with
it there. In the macro that line will be green. Remove the '
 
I have tried this macro but it is inserting the date I created the file.
How do I get it to insert TODAY's date?? Could I make CREATEDATE something
else??
 
Thank you VERY much. Took that out and it works just like it should. Any
idea why that was there? I did *not* put it there. As I said, I copied and
pasted what you had written.
 
When you create a macro, there are 4 lines with the ' by them. One of
the lines says the name of the macro, one the creator's name and date
and 2 are empty. They are for putting in notes about the macro and are
ignored by the macro. I sometimes put notes in them about where, when,
and why it's there or who it's from. They can be deleted if you don't
want them.
Tonya Marshall
 
Back
Top