Hi,

I have been asked to modify one of our Word Macros so that the date
stays static. Currently we are using
{ DATE \@ "MMMM d, yyyy" \*MERGEFORMAT }
This is fine but when ever the document is opened again the date
changes to the current date and not the one that was supposed to be
for the Originating Date..

Could someone perhaps point me to the right place to get this
answered...

PS not a Macro or VBA expert by any means but do have scripting under
my belt...

Cheers an TIA

Ron

Re: Static Date code for macro by Graham

Graham
Mon Jun 30 07:50:40 PDT 2008

This has little to do with macros.

The obvious solution would be to change the DATE field in the document
template to a CREATEDATE field. CREATEDATE always shows the date it was
created in the template and the dates the documents created from that
template will show they dates they were created. The \*MERGEFORMAT switch
is superfluous here and can be removed from the field. Thus { CREATEDATE \@
"MMMM d, yyyy" }


If you are inserting the date from a macro then fields need not come into it
at all eg

Sub InsertUSFormatDate()
With Selection
.InsertDateTime DateTimeFormat:="MMMM" & Chr(160) & _
"d," & Chr(160) & "yyyy", InsertAsField:=False
End With
End Sub

will insert the current date as text at the cursor.

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

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


fenixdood wrote:
> Hi,
>
> I have been asked to modify one of our Word Macros so that the date
> stays static. Currently we are using
> { DATE \@ "MMMM d, yyyy" \*MERGEFORMAT }
> This is fine but when ever the document is opened again the date
> changes to the current date and not the one that was supposed to be
> for the Originating Date..
>
> Could someone perhaps point me to the right place to get this
> answered...
>
> PS not a Macro or VBA expert by any means but do have scripting under
> my belt...
>
> Cheers an TIA
>
> Ron



Re: Static Date code for macro by Jay

Jay
Mon Jun 30 07:55:59 PDT 2008

fenixdood wrote:
> Hi,
>
> I have been asked to modify one of our Word Macros so that the date
> stays static. Currently we are using
> { DATE \@ "MMMM d, yyyy" \*MERGEFORMAT }
> This is fine but when ever the document is opened again the date
> changes to the current date and not the one that was supposed to be
> for the Originating Date..
>
> Could someone perhaps point me to the right place to get this
> answered...
>
> PS not a Macro or VBA expert by any means but do have scripting under
> my belt...
>
> Cheers an TIA
>
> Ron

The usual answer is to use a CREATEDATE field instead of a DATE field. That
will always display the date the document was created, either by making a
new document based on the template or by using Save As from an existing
document.

If the creation date isn't what you want, you can instead either lock or
unlink the DATE field when it's showing the correct date. Locking the field
(in code, if the variable myField points to the DATE field in question,
execute myField.Locked = True) prevents the field from updating until you
unlock it. Unlinking the field (in code, execute myField.Unlink) replaces
the field with the plain text of its current value, which of course will
never update.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.



Re: Static Date code for macro by Fenixdood

Fenixdood
Wed Jul 02 09:13:01 PDT 2008

Thanks for the info..

caviat is...I used the CreateDate but it inputs the date the template was
created. I am in need of a user who creates a new document from template.
then the date is hard coded immediatley and will not change..

not too sure how the VB code should be on this one.. can you help out..?.

Cheers
Ron

"Jay Freedman" wrote:

> fenixdood wrote:
> > Hi,
> >
> > I have been asked to modify one of our Word Macros so that the date
> > stays static. Currently we are using
> > { DATE \@ "MMMM d, yyyy" \*MERGEFORMAT }
> > This is fine but when ever the document is opened again the date
> > changes to the current date and not the one that was supposed to be
> > for the Originating Date..
> >
> > Could someone perhaps point me to the right place to get this
> > answered...
> >
> > PS not a Macro or VBA expert by any means but do have scripting under
> > my belt...
> >
> > Cheers an TIA
> >
> > Ron
>
> The usual answer is to use a CREATEDATE field instead of a DATE field. That
> will always display the date the document was created, either by making a
> new document based on the template or by using Save As from an existing
> document.
>
> If the creation date isn't what you want, you can instead either lock or
> unlink the DATE field when it's showing the correct date. Locking the field
> (in code, if the variable myField points to the DATE field in question,
> execute myField.Locked = True) prevents the field from updating until you
> unlock it. Unlinking the field (in code, execute myField.Unlink) replaces
> the field with the plain text of its current value, which of course will
> never update.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> all may benefit.
>
>
>

Re: Static Date code for macro by Jay

Jay
Wed Jul 02 18:57:53 PDT 2008

In the template itself, the CreateDate field will show the template's date of
creation. When you base a new document on the template, it _will_ show the
document's date of creation, not the template's.

Of course it would be possible to write an AutoNew macro to insert the current
date as plain text, but that would be reinventing the wheel because the
CreateDate field does exactly what you're asking for.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.

On Wed, 2 Jul 2008 09:13:01 -0700, Fenixdood
<Fenixdood@discussions.microsoft.com> wrote:

>Thanks for the info..
>
>caviat is...I used the CreateDate but it inputs the date the template was
>created. I am in need of a user who creates a new document from template.
>then the date is hard coded immediatley and will not change..
>
>not too sure how the VB code should be on this one.. can you help out..?.
>
>Cheers
>Ron
>
>"Jay Freedman" wrote:
>
>> fenixdood wrote:
>> > Hi,
>> >
>> > I have been asked to modify one of our Word Macros so that the date
>> > stays static. Currently we are using
>> > { DATE \@ "MMMM d, yyyy" \*MERGEFORMAT }
>> > This is fine but when ever the document is opened again the date
>> > changes to the current date and not the one that was supposed to be
>> > for the Originating Date..
>> >
>> > Could someone perhaps point me to the right place to get this
>> > answered...
>> >
>> > PS not a Macro or VBA expert by any means but do have scripting under
>> > my belt...
>> >
>> > Cheers an TIA
>> >
>> > Ron
>>
>> The usual answer is to use a CREATEDATE field instead of a DATE field. That
>> will always display the date the document was created, either by making a
>> new document based on the template or by using Save As from an existing
>> document.
>>
>> If the creation date isn't what you want, you can instead either lock or
>> unlink the DATE field when it's showing the correct date. Locking the field
>> (in code, if the variable myField points to the DATE field in question,
>> execute myField.Locked = True) prevents the field from updating until you
>> unlock it. Unlinking the field (in code, execute myField.Unlink) replaces
>> the field with the plain text of its current value, which of course will
>> never update.
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
>> all may benefit.
>>
>>
>>

Re: Static Date code for macro by Fenixdood

Fenixdood
Thu Jul 03 07:03:02 PDT 2008

Thanks for your insight..

My Findings..firstly I am new to this Company and still learning how they
operate..
So..the documents in question are not .dot but rather.doc..we use an
application (ms access based) and then generate letters using mail merge,
pulling data from the DB and then into a letter in word.
I changed the format of the document i am testing to a .dot. and it seems
the date field appears..So i take it that the letters which are in .doc
format need to be in .dot format.. do you think I have this correct?

TIA
Ron

"Jay Freedman" wrote:

> In the template itself, the CreateDate field will show the template's date of
> creation. When you base a new document on the template, it _will_ show the
> document's date of creation, not the template's.
>
> Of course it would be possible to write an AutoNew macro to insert the current
> date as plain text, but that would be reinventing the wheel because the
> CreateDate field does exactly what you're asking for.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
> may benefit.
>
> On Wed, 2 Jul 2008 09:13:01 -0700, Fenixdood
> <Fenixdood@discussions.microsoft.com> wrote:
>
> >Thanks for the info..
> >
> >caviat is...I used the CreateDate but it inputs the date the template was
> >created. I am in need of a user who creates a new document from template.
> >then the date is hard coded immediatley and will not change..
> >
> >not too sure how the VB code should be on this one.. can you help out..?.
> >
> >Cheers
> >Ron
> >
> >"Jay Freedman" wrote:
> >
> >> fenixdood wrote:
> >> > Hi,
> >> >
> >> > I have been asked to modify one of our Word Macros so that the date
> >> > stays static. Currently we are using
> >> > { DATE \@ "MMMM d, yyyy" \*MERGEFORMAT }
> >> > This is fine but when ever the document is opened again the date
> >> > changes to the current date and not the one that was supposed to be
> >> > for the Originating Date..
> >> >
> >> > Could someone perhaps point me to the right place to get this
> >> > answered...
> >> >
> >> > PS not a Macro or VBA expert by any means but do have scripting under
> >> > my belt...
> >> >
> >> > Cheers an TIA
> >> >
> >> > Ron
> >>
> >> The usual answer is to use a CREATEDATE field instead of a DATE field. That
> >> will always display the date the document was created, either by making a
> >> new document based on the template or by using Save As from an existing
> >> document.
> >>
> >> If the creation date isn't what you want, you can instead either lock or
> >> unlink the DATE field when it's showing the correct date. Locking the field
> >> (in code, if the variable myField points to the DATE field in question,
> >> execute myField.Locked = True) prevents the field from updating until you
> >> unlock it. Unlinking the field (in code, execute myField.Unlink) replaces
> >> the field with the plain text of its current value, which of course will
> >> never update.
> >>
> >> --
> >> Regards,
> >> Jay Freedman
> >> Microsoft Word MVP FAQ: http://word.mvps.org
> >> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> >> all may benefit.
> >>
> >>
> >>
>

Re: Static Date code for macro by Jay

Jay
Thu Jul 03 15:11:35 PDT 2008

You may be correct, but I have no idea what your Access application is doing so
I can't be sure. I think the only way you'll find out is to try it.

Generally, a CreateDate field in a document will show the correct date if (a)
the document is created by the File > New command (or its VBA equivalent,
Documents.Add) based on a template, or (b) you use File > Save As (or its VBA
equivalent) to make a copy of an existing document.

If the Access application does one of these two things, then the field should
work. If you can't get it to work, the best alternative will be to alter the
Access application to insert the current date in the document (probably at a
predefined bookmark) as plain text. Unfortunately, I can't help much with that.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.

On Thu, 3 Jul 2008 07:03:02 -0700, Fenixdood
<Fenixdood@discussions.microsoft.com> wrote:

>Thanks for your insight..
>
>My Findings..firstly I am new to this Company and still learning how they
>operate..
>So..the documents in question are not .dot but rather.doc..we use an
>application (ms access based) and then generate letters using mail merge,
>pulling data from the DB and then into a letter in word.
>I changed the format of the document i am testing to a .dot. and it seems
>the date field appears..So i take it that the letters which are in .doc
>format need to be in .dot format.. do you think I have this correct?
>
>TIA
>Ron
>
>"Jay Freedman" wrote:
>
>> In the template itself, the CreateDate field will show the template's date of
>> creation. When you base a new document on the template, it _will_ show the
>> document's date of creation, not the template's.
>>
>> Of course it would be possible to write an AutoNew macro to insert the current
>> date as plain text, but that would be reinventing the wheel because the
>> CreateDate field does exactly what you're asking for.
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
>> may benefit.
>>
>> On Wed, 2 Jul 2008 09:13:01 -0700, Fenixdood
>> <Fenixdood@discussions.microsoft.com> wrote:
>>
>> >Thanks for the info..
>> >
>> >caviat is...I used the CreateDate but it inputs the date the template was
>> >created. I am in need of a user who creates a new document from template.
>> >then the date is hard coded immediatley and will not change..
>> >
>> >not too sure how the VB code should be on this one.. can you help out..?.
>> >
>> >Cheers
>> >Ron
>> >
>> >"Jay Freedman" wrote:
>> >
>> >> fenixdood wrote:
>> >> > Hi,
>> >> >
>> >> > I have been asked to modify one of our Word Macros so that the date
>> >> > stays static. Currently we are using
>> >> > { DATE \@ "MMMM d, yyyy" \*MERGEFORMAT }
>> >> > This is fine but when ever the document is opened again the date
>> >> > changes to the current date and not the one that was supposed to be
>> >> > for the Originating Date..
>> >> >
>> >> > Could someone perhaps point me to the right place to get this
>> >> > answered...
>> >> >
>> >> > PS not a Macro or VBA expert by any means but do have scripting under
>> >> > my belt...
>> >> >
>> >> > Cheers an TIA
>> >> >
>> >> > Ron
>> >>
>> >> The usual answer is to use a CREATEDATE field instead of a DATE field. That
>> >> will always display the date the document was created, either by making a
>> >> new document based on the template or by using Save As from an existing
>> >> document.
>> >>
>> >> If the creation date isn't what you want, you can instead either lock or
>> >> unlink the DATE field when it's showing the correct date. Locking the field
>> >> (in code, if the variable myField points to the DATE field in question,
>> >> execute myField.Locked = True) prevents the field from updating until you
>> >> unlock it. Unlinking the field (in code, execute myField.Unlink) replaces
>> >> the field with the plain text of its current value, which of course will
>> >> never update.
>> >>
>> >> --
>> >> Regards,
>> >> Jay Freedman
>> >> Microsoft Word MVP FAQ: http://word.mvps.org
>> >> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
>> >> all may benefit.
>> >>
>> >>
>> >>
>>

Re: Static Date code for macro by Fenixdood

Fenixdood
Tue Jul 08 10:35:04 PDT 2008

Thanks for your help jay...Seems to be working now... one thing is do you now
what I need to do to have the Date displyed in bold font..it was bold before
I adjusted things now the text is simple font..I am looking for a clue...

Regards
R

"Jay Freedman" wrote:

> You may be correct, but I have no idea what your Access application is doing so
> I can't be sure. I think the only way you'll find out is to try it.
>
> Generally, a CreateDate field in a document will show the correct date if (a)
> the document is created by the File > New command (or its VBA equivalent,
> Documents.Add) based on a template, or (b) you use File > Save As (or its VBA
> equivalent) to make a copy of an existing document.
>
> If the Access application does one of these two things, then the field should
> work. If you can't get it to work, the best alternative will be to alter the
> Access application to insert the current date in the document (probably at a
> predefined bookmark) as plain text. Unfortunately, I can't help much with that.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
> may benefit.
>
> On Thu, 3 Jul 2008 07:03:02 -0700, Fenixdood
> <Fenixdood@discussions.microsoft.com> wrote:
>
> >Thanks for your insight..
> >
> >My Findings..firstly I am new to this Company and still learning how they
> >operate..
> >So..the documents in question are not .dot but rather.doc..we use an
> >application (ms access based) and then generate letters using mail merge,
> >pulling data from the DB and then into a letter in word.
> >I changed the format of the document i am testing to a .dot. and it seems
> >the date field appears..So i take it that the letters which are in .doc
> >format need to be in .dot format.. do you think I have this correct?
> >
> >TIA
> >Ron
> >
> >"Jay Freedman" wrote:
> >
> >> In the template itself, the CreateDate field will show the template's date of
> >> creation. When you base a new document on the template, it _will_ show the
> >> document's date of creation, not the template's.
> >>
> >> Of course it would be possible to write an AutoNew macro to insert the current
> >> date as plain text, but that would be reinventing the wheel because the
> >> CreateDate field does exactly what you're asking for.
> >>
> >> --
> >> Regards,
> >> Jay Freedman
> >> Microsoft Word MVP FAQ: http://word.mvps.org
> >> Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
> >> may benefit.
> >>
> >> On Wed, 2 Jul 2008 09:13:01 -0700, Fenixdood
> >> <Fenixdood@discussions.microsoft.com> wrote:
> >>
> >> >Thanks for the info..
> >> >
> >> >caviat is...I used the CreateDate but it inputs the date the template was
> >> >created. I am in need of a user who creates a new document from template.
> >> >then the date is hard coded immediatley and will not change..
> >> >
> >> >not too sure how the VB code should be on this one.. can you help out..?.
> >> >
> >> >Cheers
> >> >Ron
> >> >
> >> >"Jay Freedman" wrote:
> >> >
> >> >> fenixdood wrote:
> >> >> > Hi,
> >> >> >
> >> >> > I have been asked to modify one of our Word Macros so that the date
> >> >> > stays static. Currently we are using
> >> >> > { DATE \@ "MMMM d, yyyy" \*MERGEFORMAT }
> >> >> > This is fine but when ever the document is opened again the date
> >> >> > changes to the current date and not the one that was supposed to be
> >> >> > for the Originating Date..
> >> >> >
> >> >> > Could someone perhaps point me to the right place to get this
> >> >> > answered...
> >> >> >
> >> >> > PS not a Macro or VBA expert by any means but do have scripting under
> >> >> > my belt...
> >> >> >
> >> >> > Cheers an TIA
> >> >> >
> >> >> > Ron
> >> >>
> >> >> The usual answer is to use a CREATEDATE field instead of a DATE field. That
> >> >> will always display the date the document was created, either by making a
> >> >> new document based on the template or by using Save As from an existing
> >> >> document.
> >> >>
> >> >> If the creation date isn't what you want, you can instead either lock or
> >> >> unlink the DATE field when it's showing the correct date. Locking the field
> >> >> (in code, if the variable myField points to the DATE field in question,
> >> >> execute myField.Locked = True) prevents the field from updating until you
> >> >> unlock it. Unlinking the field (in code, execute myField.Unlink) replaces
> >> >> the field with the plain text of its current value, which of course will
> >> >> never update.
> >> >>
> >> >> --
> >> >> Regards,
> >> >> Jay Freedman
> >> >> Microsoft Word MVP FAQ: http://word.mvps.org
> >> >> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> >> >> all may benefit.
> >> >>
> >> >>
> >> >>
> >>
>

Re: Static Date code for macro by Jay

Jay
Tue Jul 08 10:53:15 PDT 2008

Use either the \*Charformat switch or the \*Mergeformat switch in the field
code. For explanations, go to
http://www.gmayor.com/formatting_word_fields.htm and scroll down to the
section "Character formats and protecting previously applied formats".

Fenixdood wrote:
> Thanks for your help jay...Seems to be working now... one thing is do
> you now what I need to do to have the Date displyed in bold font..it
> was bold before I adjusted things now the text is simple font..I am
> looking for a clue...
>
> Regards
> R
>
> "Jay Freedman" wrote:
>
>> You may be correct, but I have no idea what your Access application
>> is doing so I can't be sure. I think the only way you'll find out is
>> to try it.
>>
>> Generally, a CreateDate field in a document will show the correct
>> date if (a) the document is created by the File > New command (or
>> its VBA equivalent, Documents.Add) based on a template, or (b) you
>> use File > Save As (or its VBA equivalent) to make a copy of an
>> existing document.
>>
>> If the Access application does one of these two things, then the
>> field should work. If you can't get it to work, the best alternative
>> will be to alter the Access application to insert the current date
>> in the document (probably at a predefined bookmark) as plain text.
>> Unfortunately, I can't help much with that.
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.
>>
>> On Thu, 3 Jul 2008 07:03:02 -0700, Fenixdood
>> <Fenixdood@discussions.microsoft.com> wrote:
>>
>>> Thanks for your insight..
>>>
>>> My Findings..firstly I am new to this Company and still learning
>>> how they operate..
>>> So..the documents in question are not .dot but rather.doc..we use an
>>> application (ms access based) and then generate letters using mail
>>> merge, pulling data from the DB and then into a letter in word.
>>> I changed the format of the document i am testing to a .dot. and it
>>> seems the date field appears..So i take it that the letters which
>>> are in .doc format need to be in .dot format.. do you think I have
>>> this correct?
>>>
>>> TIA
>>> Ron
>>>
>>> "Jay Freedman" wrote:
>>>
>>>> In the template itself, the CreateDate field will show the
>>>> template's date of creation. When you base a new document on the
>>>> template, it _will_ show the document's date of creation, not the
>>>> template's.
>>>>
>>>> Of course it would be possible to write an AutoNew macro to insert
>>>> the current date as plain text, but that would be reinventing the
>>>> wheel because the CreateDate field does exactly what you're asking
>>>> for.
>>>>
>>>> --
>>>> Regards,
>>>> Jay Freedman
>>>> Microsoft Word MVP FAQ: http://word.mvps.org
>>>> Email cannot be acknowledged; please post all follow-ups to the
>>>> newsgroup so all may benefit.
>>>>
>>>> On Wed, 2 Jul 2008 09:13:01 -0700, Fenixdood
>>>> <Fenixdood@discussions.microsoft.com> wrote:
>>>>
>>>>> Thanks for the info..
>>>>>
>>>>> caviat is...I used the CreateDate but it inputs the date the
>>>>> template was created. I am in need of a user who creates a new
>>>>> document from template. then the date is hard coded immediatley
>>>>> and will not change..
>>>>>
>>>>> not too sure how the VB code should be on this one.. can you help
>>>>> out..?.
>>>>>
>>>>> Cheers
>>>>> Ron
>>>>>
>>>>> "Jay Freedman" wrote:
>>>>>
>>>>>> fenixdood wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have been asked to modify one of our Word Macros so that the
>>>>>>> date stays static. Currently we are using
>>>>>>> { DATE \@ "MMMM d, yyyy" \*MERGEFORMAT }
>>>>>>> This is fine but when ever the document is opened again the date
>>>>>>> changes to the current date and not the one that was supposed
>>>>>>> to be for the Originating Date..
>>>>>>>
>>>>>>> Could someone perhaps point me to the right place to get this
>>>>>>> answered...
>>>>>>>
>>>>>>> PS not a Macro or VBA expert by any means but do have scripting
>>>>>>> under my belt...
>>>>>>>
>>>>>>> Cheers an TIA
>>>>>>>
>>>>>>> Ron
>>>>>>
>>>>>> The usual answer is to use a CREATEDATE field instead of a DATE
>>>>>> field. That will always display the date the document was
>>>>>> created, either by making a new document based on the template
>>>>>> or by using Save As from an existing document.
>>>>>>
>>>>>> If the creation date isn't what you want, you can instead either
>>>>>> lock or unlink the DATE field when it's showing the correct
>>>>>> date. Locking the field (in code, if the variable myField points
>>>>>> to the DATE field in question, execute myField.Locked = True)
>>>>>> prevents the field from updating until you unlock it. Unlinking
>>>>>> the field (in code, execute myField.Unlink) replaces the field
>>>>>> with the plain text of its current value, which of course will
>>>>>> never update.
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Jay Freedman
>>>>>> Microsoft Word MVP FAQ: http://word.mvps.org
>>>>>> Email cannot be acknowledged; please post all follow-ups to the
>>>>>> newsgroup so all may benefit.