Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Deejay Deejay is offline
external usenet poster
 
Posts: 52
Default Userinitials not updating automatically

I have a field which has USERINITIALS but which does not update unless I
press F9. According to the Word help it should update automatically when the
file is opened. So am I doing something wrong?

Thanks!
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Userinitials not updating automatically

Simply opening an existing document will not normally cause the field to
update (creating a new document with such a field will create the document
with the current information). If you want to force an update to the fields
in the document every time you open the document, then in its template,
create an autoopen macro (or add to any existing autoopen macro) with the
update code from 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


Deejay wrote:
I have a field which has USERINITIALS but which does not update
unless I press F9. According to the Word help it should update
automatically when the file is opened. So am I doing something wrong?

Thanks!



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Deejay Deejay is offline
external usenet poster
 
Posts: 52
Default Userinitials not updating automatically

Thank you for your reply.

This is a quote from the Help file which is not quite true:

Control how fields are updated
By default, Word automatically updates fields when a document is opened.
That way, information stays up to date.

My file is being created by another program which copies files rather than
creates new ones from templates. What I would like to do is an autoopen macro
which first checks the value and then decides with an if statement whether to
update or not. But how do I refer to a specific field in the macro? In Excel
it's easy because everything is in a cell with its own number, but how do you
point to a specific field in Word?

"Graham Mayor" wrote:

Simply opening an existing document will not normally cause the field to
update (creating a new document with such a field will create the document
with the current information). If you want to force an update to the fields
in the document every time you open the document, then in its template,
create an autoopen macro (or add to any existing autoopen macro) with the
update code from 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


Deejay wrote:
I have a field which has USERINITIALS but which does not update
unless I press F9. According to the Word help it should update
automatically when the file is opened. So am I doing something wrong?

Thanks!




  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Helmut Weber Helmut Weber is offline
external usenet poster
 
Posts: 139
Default Userinitials not updating automatically

Hi Deejay,

e.g.

Sub Test459()
' update all fields of type wdFieldUserInitials
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
oFld.Update
End If
Next
End Sub

Sub Test459b()
' update second field of type wdFieldUserInitials
Dim oFld As Field ' a field
Dim cFld As Collection ' a collection
Set cFld = New Collection
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
' add only fields of type wdFieldUserInitials
' to the collection
cFld.Add oFld
End If
Next
cFld(2).Update
End Sub

Still better would be to enclose the fields in question
in bookmarks at the time they are created.

Maybe I'm missing something.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"


  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Deejay Deejay is offline
external usenet poster
 
Posts: 52
Default Userinitials not updating automatically

Thanks. That's fine, but it must also check the value in the field. This is
because it only needs updating the first time it is created. Once the letter
is done, it shouldn't be updated every time it's opened.

"Helmut Weber" wrote:

Hi Deejay,

e.g.

Sub Test459()
' update all fields of type wdFieldUserInitials
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
oFld.Update
End If
Next
End Sub

Sub Test459b()
' update second field of type wdFieldUserInitials
Dim oFld As Field ' a field
Dim cFld As Collection ' a collection
Set cFld = New Collection
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
' add only fields of type wdFieldUserInitials
' to the collection
cFld.Add oFld
End If
Next
cFld(2).Update
End Sub

Still better would be to enclose the fields in question
in bookmarks at the time they are created.

Maybe I'm missing something.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"





  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Helmut Weber Helmut Weber is offline
external usenet poster
 
Posts: 139
Default Userinitials not updating automatically

Hi Deejay,

but it must also check the value in the field.


if ofld.Result = "hw" then ...

because it only needs updating the first time it is created.


This is a special challenge.
You got to store somewhere a boolean value
or a string or a number representing a boolean value
of kind "WasUpdated" in the document.
A doc-variable or a doc-property.

I have to leave you alone with this for a while,
but I'm sure, Graham is reading this
and will help you further on.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Userinitials not updating automatically

You seem to have changed your requirement. Either you want the field
updating when you open the document, as originally stated, or you don't.
Perhaps you can tell us exactly what the requirement is here? If you simply
want to insert the user initials of the document creator and get them to
stick through thick and thin, then you either need to convert the field to
text or abandon the field and insert the initials with vba.

Sub Macro2()
Dim oFld As Field
Dim sInit as String
sInit = "GM" ' Set required initials
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
If oFld.Result sInit Then
oFld.Update
oFld.Unlink
End If
End If
Next

or

Dim sInit As String
sInit = Application.UserInitials
Selection.TypeText sInit

--

Graham Mayor - Word MVP

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



Deejay wrote:
Thanks. That's fine, but it must also check the value in the field.
This is because it only needs updating the first time it is created.
Once the letter is done, it shouldn't be updated every time it's
opened.

"Helmut Weber" wrote:

Hi Deejay,

e.g.

Sub Test459()
' update all fields of type wdFieldUserInitials
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
oFld.Update
End If
Next
End Sub

Sub Test459b()
' update second field of type wdFieldUserInitials
Dim oFld As Field ' a field
Dim cFld As Collection ' a collection
Set cFld = New Collection
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
' add only fields of type wdFieldUserInitials
' to the collection
cFld.Add oFld
End If
Next
cFld(2).Update
End Sub

Still better would be to enclose the fields in question
in bookmarks at the time they are created.

Maybe I'm missing something.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



  #8   Report Post  
Posted to microsoft.public.word.docmanagement
Deejay Deejay is offline
external usenet poster
 
Posts: 52
Default Userinitials not updating automatically

Sorry if I wasn't clear enough. In the template there is a field with
USERINITIALS of which the value is, say, 'ab'. When a new document is created
by, say, 'cd' the value of the above field remains 'ab'. So I wish to change
it to 'cd' or whoever the author of the new documents is when the document is
created. Once the doc. is created this value must remain constant
irrespective of who opens the file later.

"Graham Mayor" wrote:

You seem to have changed your requirement. Either you want the field
updating when you open the document, as originally stated, or you don't.
Perhaps you can tell us exactly what the requirement is here? If you simply
want to insert the user initials of the document creator and get them to
stick through thick and thin, then you either need to convert the field to
text or abandon the field and insert the initials with vba.

Sub Macro2()
Dim oFld As Field
Dim sInit as String
sInit = "GM" ' Set required initials
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
If oFld.Result sInit Then
oFld.Update
oFld.Unlink
End If
End If
Next

or

Dim sInit As String
sInit = Application.UserInitials
Selection.TypeText sInit

--

Graham Mayor - Word MVP

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



Deejay wrote:
Thanks. That's fine, but it must also check the value in the field.
This is because it only needs updating the first time it is created.
Once the letter is done, it shouldn't be updated every time it's
opened.

"Helmut Weber" wrote:

Hi Deejay,

e.g.

Sub Test459()
' update all fields of type wdFieldUserInitials
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
oFld.Update
End If
Next
End Sub

Sub Test459b()
' update second field of type wdFieldUserInitials
Dim oFld As Field ' a field
Dim cFld As Collection ' a collection
Set cFld = New Collection
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
' add only fields of type wdFieldUserInitials
' to the collection
cFld.Add oFld
End If
Next
cFld(2).Update
End Sub

Still better would be to enclose the fields in question
in bookmarks at the time they are created.

Maybe I'm missing something.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"




  #9   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Userinitials not updating automatically

The standard setup should already achieve that. If a new document is
created, the field should reflect the user of the PC where the document was
created. What the field in the template shows as a result is hardly
relevant. However to prevent accidental updating and to force an update on
creation of a new document, you need the following macro in the document
template.

Sub AutoNew()
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
oFld.Update
oFld.Unlink
End If
Next
End Sub

This will update any UserInitials fields in the document and convert to
text, so they are no longer fields which may be updated.

--

Graham Mayor - Word MVP

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


Deejay wrote:
Sorry if I wasn't clear enough. In the template there is a field with
USERINITIALS of which the value is, say, 'ab'. When a new document is
created by, say, 'cd' the value of the above field remains 'ab'. So I
wish to change it to 'cd' or whoever the author of the new documents
is when the document is created. Once the doc. is created this value
must remain constant irrespective of who opens the file later.

"Graham Mayor" wrote:

You seem to have changed your requirement. Either you want the field
updating when you open the document, as originally stated, or you
don't. Perhaps you can tell us exactly what the requirement is here?
If you simply want to insert the user initials of the document
creator and get them to stick through thick and thin, then you
either need to convert the field to text or abandon the field and
insert the initials with vba.

Sub Macro2()
Dim oFld As Field
Dim sInit as String
sInit = "GM" ' Set required initials
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
If oFld.Result sInit Then
oFld.Update
oFld.Unlink
End If
End If
Next

or

Dim sInit As String
sInit = Application.UserInitials
Selection.TypeText sInit

--

Graham Mayor - Word MVP

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



Deejay wrote:
Thanks. That's fine, but it must also check the value in the field.
This is because it only needs updating the first time it is created.
Once the letter is done, it shouldn't be updated every time it's
opened.

"Helmut Weber" wrote:

Hi Deejay,

e.g.

Sub Test459()
' update all fields of type wdFieldUserInitials
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
oFld.Update
End If
Next
End Sub

Sub Test459b()
' update second field of type wdFieldUserInitials
Dim oFld As Field ' a field
Dim cFld As Collection ' a collection
Set cFld = New Collection
For Each oFld In ActiveDocument.Fields
If oFld.Type = wdFieldUserInitials Then
' add only fields of type wdFieldUserInitials
' to the collection
cFld.Add oFld
End If
Next
cFld(2).Update
End Sub

Still better would be to enclose the fields in question
in bookmarks at the time they are created.

Maybe I'm missing something.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Links not automatically updating. TLN[_2_] Microsoft Word Help 1 May 28th 07 06:34 PM
Updating fields automatically? jezzica85 Microsoft Word Help 3 February 24th 07 07:30 AM
Date Automatically Updating denise Microsoft Word Help 8 October 26th 06 06:53 PM
Updating dates automatically HastingsF Microsoft Word Help 1 August 8th 06 04:39 AM
Automatically updating Fields in Word? JRae Microsoft Word Help 1 May 14th 05 03:02 AM


All times are GMT +1. The time now is 10:12 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"