Using the "SET" command

B

Bill

I have a document that I'd like to add a
"SET" command to initialize what amounts
to a document variable. I.e., I set the variable
and then use the variable to insert its value
amongst the text of the document.

Example:

{SET DOT "revise this string when date becomes available"}

blah blah blah {DOT}
blah blah
blah
blah {DOT}
blah blah
blah blah blah
blah
{DOT}

I coded the DOT variable name as you see above but
the substitutions are not occurring. Do I misunderstand
the use of field codes?

Thanks,
Bill
 
J

Jezebel

The SET command is a way to define a bookmark. To refer to the contents of a
bookmark, use REF fields ... so in place of your {DOT} instructions you
should have {REF DOT}.

However, you might find it easier to use a document property instead: define
the 'variable' on File > Properties > Custom, then use a docproperty field
{ DocProperty DOT } to display the value. This has three advantages: 1) it's
a little easier to see what the value is set to, 2) there's no danger of
accidentally deleting the instruction that sets the value -- SET
instructions are necessarily invisible when field codes are hidden, so it's
easy to forget that they are there, and 3) document properties are easier to
read and set programmatically.
 
B

Bill

Jezebel,
I tried your suggestion with the document properties
by defining the variable name fldDOT and setting its
value to a string. Then, I coded {DocProperty fldDOT}
in my document where I wanted the string to appear
but the substitution did not occur, as one would expect
with bookmark and cross-reference.

Did I not understand your instructions?

Thanks,
Bill
 
J

Jezebel

You also need to update fields -- this applies to using the SET method, or
indeed any kind of field. Select the field (or the entire document) and
press F9. This refreshes the display with the current field contents, so
you'll need to do it again if you change the value. Updating normally
happens automatically when you open the document, and there's an option for
it to happen when you print. If you have fields in headers, footers,
textboxes, etc, you need to update those separately.
 
D

Doug Robbins

Did you use the File>Properties dialog to create and assign the value to the
Custom Property?
--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
B

Bill

Yes... and I thought I'd also performed the update as
well, but now that Jezebel mentions that I'll have to
re-try.
 
B

Bill

I indeed used F9 to initiate an update, both with
Edit -> Select All and simply selecting the
{docproperty fldDOT} to effect a change there
only. Still no substitution.

I re-visited the document properties and everything
there looks ok. Is there special case sensitive or
format requirements for the {docproperty fldDOT}
expression?

Thanks,
Bill
 
B

Bill

It makes the substitution if I use the Insert ->
Field -> DocProperty -> Options and
Add-In the variable name.
 
D

Doug Robbins

Were you using Ctrl+F9 to insert the Field Delimiters { } ?

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
B

Bill

no



Doug Robbins said:
Were you using Ctrl+F9 to insert the Field Delimiters { } ?

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a
paid consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
B

Bill

Cntl+F9 was the problem. I was simply typing curly
brackets with the keyboard... wow, talk about live
and learn.
Thanks to you and Jezebel.
Bill
 
B

Bill

Jezebel,
See my post to Doug. (I wasn't using Cntl+F9
to insert the field delimiters.)
Thanks again,
Bill
 
B

Bill

Jezebel,
Thanks for the enlightenment regarding the use of the
document properties. That really gives me a much
better sense of control over what gets substituted
and "where" all such items are that require attention
later in the creation process. And, like you say, not
so vulnerable to getting lost in the shuffle.

Bill
 
Top