Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

formatting date field inserted by macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Oerjan - 18 Mar 2008 10:34 GMT
Hi,

Sorry if this has been asked recently.

I want a macro to insert a customized date.

I understand that I can insert an unformatted date field with
.Fields.Add and  Type:=wdFieldDate and then S&R the code inside the
field but I would like to directly insert a correctly formatted field.

I have tried to type the field code with Selection.Text = "  ", but I
do not manage to get those special field brackets into the Editor.

TIA
Örjan
Jonathan West - 18 Mar 2008 10:51 GMT
> Hi,
>
[quoted text clipped - 11 lines]
> TIA
> Örjan

Hi Örjan

In the Fields.Add method, there is a Text parameter. Put your formatting
switches there.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

Doug Robbins - Word MVP - 18 Mar 2008 10:54 GMT
ActiveDocument.Fields.Add Selection.Range, wdFieldDate, "\@ " & Chr(34) &
"dd MMMM yyyy" & Chr(34)

will insert 18 March 2008 and the location of the Selection

Signature

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

> Hi,
>
[quoted text clipped - 11 lines]
> TIA
> Örjan
Oerjan - 18 Mar 2008 12:27 GMT
Thanks a lot.

Örjan

>ActiveDocument.Fields.Add Selection.Range, wdFieldDate, "\@ " & Chr(34) &
>"dd MMMM yyyy" & Chr(34)
>
>will insert 18 March 2008 and the location of the Selection
Edward Thrashcort - 18 Mar 2008 13:23 GMT
Try recording a macro while you add the field

Eddie
> *From:* Oerjan <nospam@fake.se>
> *Date:* Tue, 18 Mar 2008 10:34:39 +0100
[quoted text clipped - 14 lines]
> TIA
> Örjan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.