Lock cell for text entry - allow field update only? Also, floatingcomment?

E

Ed from AZ

In Word 2007, I would like to lock a table cell against users entering
text. I have a field code there which references text from elsewhere
in the document. I want to prevent the users from "helping" me by
entering text and overwriting the field code. But however it's
locked, I need to allow the field to update.

Also, can I set up a "floating comment" in that table cell, kind of
like an Excel comment, to let the user know not to try to enter text?

Thanks.
Ed
 
P

Peter Jamieson

I am not sure you can do this using the old-style fields. I think there is
/a/ way to achieve most of what you want in Word 2007 using content
controls, but I have not used it for real (so e.g. it may be much easier to
break than I think), and it's not a particularly straightforward way.

By way of example, let's suppose you use Insert->Quick Parts->Document
Property->Comments

to insert a plain text content control that inserts the built-in Comments
document property. (if you use the method suggested in this post, you will
eventually want to use your own Content Control rather than rely on the
built-in properties - for that, I suggest you visit Greg Maxey's page at
http://gregmaxey.mvps.org/Mapped_Content_Control.htm )

Insert another copy of that Comments document property content control. Then
type some text in the control and click outside the control. You should see
the content of the other copy update immediately. This is different from the
behaviour of old-style fields where the user typically had to do something
for e.g. the results of REF fields to be updated. e.g. they might have to
select everything and press F9, or go into print preview, or print, or save
and re-open. But the content control values are linked to a data store in
the .docx and when the dta changes, the control contents change.

OK, now let's imagine you have the following document structure:

some text and other material including a copy of the Comments Content
Control.
a table
some more text and other stuff

In one cell in that table you want a cell whose content the users cannot
update.

First, just try inserting a copy of that Comments content control in that
cell. Then, in the Developer tab, click Design Mode, and you should see some
"tags" appear either side of the control. Now right-click the control and
select Properties. (You may have to make sure you are selecting exactly the
right thing for the Properties option to appear). Set "Title" to "You can't
touch this" and check "Content Control cannot be Deleted" and "Contents
Cannot be edited". These properties only affect this instance of the
control. Click Design Mode again and notice that
a. when you click the control in the table, you see "You can't touch this".
OK, so there's no floating tooltip.
b. you can't alter the content of the control in the table
c. you can't delete the control in the table
d. if you enter text in the other copy of the control and click outside the
control, the content in the table updates.

However, that's not quite enough, because if you click in the next cell,
then left arrow, you can still type text between the content control and the
end-of-cell marker.

To prevent that (this is the part I'm not too keen on), click
Developer->Protect Document->Restrict formatting and editing. In the task
pane, ensure "Allow only this type of editing in the document" is checked,
"No changes (Read only)" is selected. Obviously, that's not much use in a
document that's intended to be edited, but we can specify that every part of
the document except that cell is an exception. So...
a. select all of the document down to the table row above the cell that
contains the content control. Check Everyone.
b. in the row containing the content control, select the cells before that
cell, and check Everyone.
c. in the row containing the content control, select the cells after that
cell, and check Everyone.
d. select the cells in the row before the cell containing the content
control, and check Everyone.
e. select everything after that row and check Everyone.

Click "Yes, Start Enforcing Protection" and add whatever passwords you want.
For test purposes, you can leave this blank.

Notice that
a. the text in the unprotected area acquires a yellow background but
previews OK
b. you can edit most of the document in the usual way
c. although you can still click in the protected cell,
- you see "You can't touch this"
- you can't edit anything
d. if you modify the comment text in the control outside the table, the
copy in the table still updates. This is important, because if you put an
old-style REF field in the cell instead of a content control, modify the
bookmark text that it references, and try to update the REF field, it does
not change in the protected part of the document. So I think you /have/ to
use a content control to do this.

The last piece of this puzzle is how to modify the data that appears in that
cell. If the content control is mapped to a built-in property, you can
modify it any way that you could modify a built-in property before, e.g.
a. insert a field such as

{ COMMENTS "new comment text" }
or
{ INFO COMMENTS "new comment text" }

and update it. (This approach only works for some of the built-in
properties - title, author, comments, keywords and subject I think)
b. use VBA to modify the value of the built-in Comments property, e.g.

Sub SetCommentsText()
ActiveDocument.BuiltInDocumentProperties(wdPropertyComments) = "even newer
text"
End Sub

or

Sub SetCommentsText()
ActiveDocument.BuiltInDocumentProperties("Comments") = "even newer text"
End Sub

If you use Greg Maxey's add-in or another approach to create your own
content control, you will probably need to update the value of the data in
the document's XML daa store to achieve the same thing. I think Greg's pages
provide enough info. to work out how to do that but post back if you can't
work it out.
 
S

Suzanne S. Barnhill

One note, Peter, wrt legacy forms. When you check the box for "Calculate on
exit" in the Form Field Options for a text or dropdown form field, a REF
field referring to that field *does* update automatically and immediately.
StyleRef fields also update immediately in any kind of document (and in
places in forms where you can't use REF fields, such as the header and
footer).
 
P

Peter Jamieson

Yes, both good points, although I think STYLEREF fields only update
automatically in headers and footers and not when they are in the body of
the document.

Incidentally, when I first looked at this problem, I wondered if it would be
possible to use legacy forms protection - if you could actually start a
continuous section break immediately before the cell you wanted to protect,
and another one immediately after, it would probably be feasible. But you
can only break before and after the row which means you can't do it unless
your cell is in a single-column table. That said, itmay be one of those
cases where there is a completely different approach that a different
description of the intent might elicit.
 
S

Suzanne S. Barnhill

In my experience, StyleRef fields update automatically (and immediately)
wherever they are placed, at least in ordinary documents--don't know about
protected ones. I'm not suggesting them or legacy forms for this assignment,
just pointing this out.
 
E

Ed from AZ

Sorry for the delay in replying. I hate it when work grabs you like
that!!

I wound up using
-- a character style in the the type-in cells I want repeated
-- a StyleRef field in the cells I want the info to show in
-- protecting everything and then unprotecting all but the forbidden
parts.

I'd have to play with Greg Maxey's instructions a bit to understand
what I'm doing, and I just didn't have time. But that is well worth
looking at, and I greatly appreciate the time both of you took to help
me out.

Ed
 

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