Copying data from one Word field to another with Tracked Changes on, but this de

M

Marrick13

Using a 2003 Word form document, I have two fields on the first page that I
want to auto update to corresponding fields on a second page. I set up a
{REF} field on page 2 and set the form field to calculate on exit. It works
perfectly after protecting the document, entering the page 1 fields, and
exiting the fields. However, when I switch on track changes and protect the
document, the {REF} fields on page 2 are deleted as soon as I enter something
in the first form field on page 1. Sometimes one is deleted, sometimes both,
and sometimes the markup shows "deleted" and sometimes it doesn't. Sounds
crazy - also sounds like a bug.

I thought a workaround would be a macro that takes the data from the fields
on page 1 and copies it to the corresponding fields on page 2, executed on
exiting each page 1 field. This way, there would be no field code on page 2
to delete. But I don't know VBA well enough to figure this out on my own and
haven't found the right code on the Net.

Greg Maxey's http://gregmaxey.mvps.org/Repeating_Data.htm doesn't address
this issue as far as I can tell (except for Word 2007). I also haven't seen
this reported as a bug on the Microsoft site or anywhere else.

Can anyone provide the code or suggest another workaround?
 
G

Graham Mayor

Why are you using track changes with a protected form?

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

Marrick13 via OfficeKB.com

Graham said:
Why are you using track changes with a protected form?
Using a 2003 Word form document, I have two fields on the first page that
I
[quoted text clipped - 26 lines]
Can anyone provide the code or suggest another workaround?

It's for a biomedical company that puts documents through a review cycle.
They want to track revisions for each reviewer. The entire form is not
protected, anyway - just page one. The remaining sections are just tables
for entry of comments and suggested changes. The page 2 fields that I want
to be auto-updated to the two page 1 fields are in an unprotected section.
 
G

Graham Mayor

Protection for forms is aimed at a particular task - preparing forms for the
collection of data. It is rarely the correct vehicle for other document
types. Documents that require free editing are better served with a useform
(or userforms) to collect the data associated with document variables and
docvariable fields to present that data. How this would pan out with your
review cycle I cannot say, but track changes will not corrupt the fields
when new information is applied by the userform. It will show instead that
the old content has been deleted and the new content will be displayed -
which I believe is the intention.

A simple userform with three text fields using the default names could be
activated with code similar to

Option Explicit
Private oVars As Variables
Private Sub CommandButton1_Click()
Set oVars = ActiveDocument.Variables
oVars("varText1").Value = Me.TextBox1.Value
oVars("varText2").Value = Me.TextBox2.Value
oVars("varText3").Value = Me.TextBox3.Value
ActiveDocument.Fields.Update
Unload Me
End Sub

which applies the values entered in the userform to three docvariables,
which can be reproduced in the document with three docvariable fields. - see
For the basics, see Word MVP FAQ - Userforms
http://word.mvps.org/FAQs/Userforms.htm

for a more in depth explanation, see
http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Marrick13 via OfficeKB.com said:
Graham said:
Why are you using track changes with a protected form?
Using a 2003 Word form document, I have two fields on the first page
that
I
[quoted text clipped - 26 lines]
Can anyone provide the code or suggest another workaround?

It's for a biomedical company that puts documents through a review cycle.
They want to track revisions for each reviewer. The entire form is not
protected, anyway - just page one. The remaining sections are just tables
for entry of comments and suggested changes. The page 2 fields that I
want
to be auto-updated to the two page 1 fields are in an unprotected section.
 
M

Marrick13 via OfficeKB.com

Graham,
Thanks so much for your help. Turns out that the tracking wasn't corrupting
or deleting the fields, just wasn't displaying the data. I actually did
manage to piece together some code that works: it copies the two fields from
one page to corresponding fields on another page while using the form and
having tracking on. The code shuts off protection and tracking on exit-entry
for those fields and switches them back on after leaving the field. A bit
awkward - and I am leaving out the password assignment to keep it simpler -
but the objective is achieved. A user form might not be a good idea in this
case because of the review cycle; reviewers need to see previous entries and
revisions. While tracking works fine on a template document using a user
form, the form would always pop up empty. This is not a single user, multi-
use form but rather a multi-user, multi-use form. You're right about
tracking not being compatible with form fields, but that was the request.

Graham said:
Protection for forms is aimed at a particular task - preparing forms for the
collection of data. It is rarely the correct vehicle for other document
types. Documents that require free editing are better served with a useform
(or userforms) to collect the data associated with document variables and
docvariable fields to present that data. How this would pan out with your
review cycle I cannot say, but track changes will not corrupt the fields
when new information is applied by the userform. It will show instead that
the old content has been deleted and the new content will be displayed -
which I believe is the intention.

A simple userform with three text fields using the default names could be
activated with code similar to

Option Explicit
Private oVars As Variables
Private Sub CommandButton1_Click()
Set oVars = ActiveDocument.Variables
oVars("varText1").Value = Me.TextBox1.Value
oVars("varText2").Value = Me.TextBox2.Value
oVars("varText3").Value = Me.TextBox3.Value
ActiveDocument.Fields.Update
Unload Me
End Sub

which applies the values entered in the userform to three docvariables,
which can be reproduced in the document with three docvariable fields. - see
For the basics, see Word MVP FAQ - Userforms
http://word.mvps.org/FAQs/Userforms.htm

for a more in depth explanation, see
http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm
[quoted text clipped - 11 lines]
want
to be auto-updated to the two page 1 fields are in an unprotected section.
 
G

Graham Mayor

Sometimes the client does not know best :)

Using the previous example, you can read the last set of variables into the
userform with an additional bit of code

Private Sub UserForm_Initialize()
On Error Resume Next
Set oVars = ActiveDocument.Variables
Me.TextBox1.Value = oVars("varText1").Value
Me.TextBox2.Value = oVars("varText2").Value
Me.TextBox3.Value = oVars("varText3").Value
End Sub

and it appears to work OK with tracking changes turned on.

Word is not a multi-user environment. Only one user can have control over
the document at a time. I'll leave you to worry about the mechanics of
handling that :)
Personally I would recommend having the document in question as a template
and create new documents as numbered and dated versions of it, so you have a
complete audit trail - see http://www.gmayor.com/save_numbered_versions.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Marrick13 via OfficeKB.com said:
Graham,
Thanks so much for your help. Turns out that the tracking wasn't
corrupting
or deleting the fields, just wasn't displaying the data. I actually did
manage to piece together some code that works: it copies the two fields
from
one page to corresponding fields on another page while using the form and
having tracking on. The code shuts off protection and tracking on
exit-entry
for those fields and switches them back on after leaving the field. A bit
awkward - and I am leaving out the password assignment to keep it
simpler -
but the objective is achieved. A user form might not be a good idea in
this
case because of the review cycle; reviewers need to see previous entries
and
revisions. While tracking works fine on a template document using a user
form, the form would always pop up empty. This is not a single user,
multi-
use form but rather a multi-user, multi-use form. You're right about
tracking not being compatible with form fields, but that was the request.

Graham said:
Protection for forms is aimed at a particular task - preparing forms for
the
collection of data. It is rarely the correct vehicle for other document
types. Documents that require free editing are better served with a
useform
(or userforms) to collect the data associated with document variables and
docvariable fields to present that data. How this would pan out with your
review cycle I cannot say, but track changes will not corrupt the fields
when new information is applied by the userform. It will show instead that
the old content has been deleted and the new content will be displayed -
which I believe is the intention.

A simple userform with three text fields using the default names could be
activated with code similar to

Option Explicit
Private oVars As Variables
Private Sub CommandButton1_Click()
Set oVars = ActiveDocument.Variables
oVars("varText1").Value = Me.TextBox1.Value
oVars("varText2").Value = Me.TextBox2.Value
oVars("varText3").Value = Me.TextBox3.Value
ActiveDocument.Fields.Update
Unload Me
End Sub

which applies the values entered in the userform to three docvariables,
which can be reproduced in the document with three docvariable fields. -
see
For the basics, see Word MVP FAQ - Userforms
http://word.mvps.org/FAQs/Userforms.htm

for a more in depth explanation, see
http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm
Why are you using track changes with a protected form?
[quoted text clipped - 11 lines]
want
to be auto-updated to the two page 1 fields are in an unprotected
section.
 
M

Marrick13 via OfficeKB.com

You're right that the client doesn't always know best. They are in a paper
environment with plans to go digital and implement Livelink. True, Word is
not a multi-user environment, but isn't the goal to have only one user with
write access to a document at a time? The numbering macro stores the
versions in the registry, but the registry is kept on the individual's
computer, is it not? If so, there would be no central repository for the
versions.

Graham said:
Sometimes the client does not know best :)

Using the previous example, you can read the last set of variables into the
userform with an additional bit of code

Private Sub UserForm_Initialize()
On Error Resume Next
Set oVars = ActiveDocument.Variables
Me.TextBox1.Value = oVars("varText1").Value
Me.TextBox2.Value = oVars("varText2").Value
Me.TextBox3.Value = oVars("varText3").Value
End Sub

and it appears to work OK with tracking changes turned on.

Word is not a multi-user environment. Only one user can have control over
the document at a time. I'll leave you to worry about the mechanics of
handling that :)
Personally I would recommend having the document in question as a template
and create new documents as numbered and dated versions of it, so you have a
complete audit trail - see http://www.gmayor.com/save_numbered_versions.htm
Graham,
Thanks so much for your help. Turns out that the tracking wasn't
[quoted text clipped - 59 lines]
 
G

Graham Mayor

Sorry - I posted the wrong link :(
Try http://www.gmayor.com/save_numbered_versions.htm
and
http://www.gmayor.com/automatic_numbering_documents.htm
both of which use an ini file which can be stored wherever you wish.
Even the original link includes a version for saving to an ini file rather
than to the registry.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



Marrick13 via OfficeKB.com said:
You're right that the client doesn't always know best. They are in a
paper
environment with plans to go digital and implement Livelink. True, Word
is
not a multi-user environment, but isn't the goal to have only one user
with
write access to a document at a time? The numbering macro stores the
versions in the registry, but the registry is kept on the individual's
computer, is it not? If so, there would be no central repository for the
versions.

Graham said:
Sometimes the client does not know best :)

Using the previous example, you can read the last set of variables into
the
userform with an additional bit of code

Private Sub UserForm_Initialize()
On Error Resume Next
Set oVars = ActiveDocument.Variables
Me.TextBox1.Value = oVars("varText1").Value
Me.TextBox2.Value = oVars("varText2").Value
Me.TextBox3.Value = oVars("varText3").Value
End Sub

and it appears to work OK with tracking changes turned on.

Word is not a multi-user environment. Only one user can have control over
the document at a time. I'll leave you to worry about the mechanics of
handling that :)
Personally I would recommend having the document in question as a template
and create new documents as numbered and dated versions of it, so you have
a
complete audit trail - see
http://www.gmayor.com/save_numbered_versions.htm
Graham,
Thanks so much for your help. Turns out that the tracking wasn't
[quoted text clipped - 59 lines]
to be auto-updated to the two page 1 fields are in an unprotected
section.
 

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