From: Elaine J. on
I want to create a macro (assigned to Control Z). that simply inserts the
current date into a document. I have looked at the date function and it
seems like it would be really easy, but for some reason I cannot come up with
the correct syntax. My user wants mm/dd/yyyy format.

Can someone help me with that?

Thanks.
From: Graham Mayor on
CTRL+Z is the undo command? It might be better to choose another!

Sub InsertUSFormatDate()
If Documents.Count = 0 Then
MsgBox "Open a document first", vbCritical, "No Document"
Exit Sub
End If
With Selection
.InsertDateTime DateTimeFormat:="MM/dd/yyyy", InsertAsField:=False
End With
End Sub

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

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



"Elaine J." <ElaineJ(a)discussions.microsoft.com> wrote in message
news:4FA0162D-3101-45B2-AE25-884020E77AA5(a)microsoft.com...
>I want to create a macro (assigned to Control Z). that simply inserts the
> current date into a document. I have looked at the date function and it
> seems like it would be really easy, but for some reason I cannot come up
> with
> the correct syntax. My user wants mm/dd/yyyy format.
>
> Can someone help me with that?
>
> Thanks.


From: Fumei2 via OfficeKB.com on
Totally agree using Ctrl-Z is not a good idea.

If you simply want the current date in the document AND you want that date to
update with whatever is the current date, then maybe use a DATE field.
Insert > Field and select the Date field. You can set it for whatever format
you want.



Graham Mayor wrote:
>CTRL+Z is the undo command? It might be better to choose another!
>
>Sub InsertUSFormatDate()
>If Documents.Count = 0 Then
> MsgBox "Open a document first", vbCritical, "No Document"
> Exit Sub
>End If
>With Selection
> .InsertDateTime DateTimeFormat:="MM/dd/yyyy", InsertAsField:=False
>End With
>End Sub
>
>http://www.gmayor.com/installing_macro.htm
>
>>I want to create a macro (assigned to Control Z). that simply inserts the
>> current date into a document. I have looked at the date function and it
>[quoted text clipped - 5 lines]
>>
>> Thanks.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/201001/1