formatting date field inserted by macro

O

Oerjan

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
 
J

Jonathan West

Oerjan said:
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

Hi Örjan

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

Doug Robbins - Word MVP

ActiveDocument.Fields.Add Selection.Range, wdFieldDate, "\@ " & Chr(34) &
"dd MMMM yyyy" & Chr(34)

will insert 18 March 2008 and the location of the Selection

--
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top