Replacing DOCPROPERTY in a rtf document

C

Chetak

Hi,

I want to use tags like this <replaceThisLater> in the rtf
document and using a perl script in unix I want to replace
it with a value later.

The problem is right now the word document has
{DOCPROPERTY replaceThisLater ... } and the changes are
done by
file>properties>custom and changing the value there.

Is there a easy way by which I can replace all the
DOCPROPERTYs by plain text tags.

for example {DOCPROPERTY sys_name \* MERGEFORMAT} by
<sys_name> ?

Thanks in Advance,
Chetak
 
G

Guest

I am not able to do Find & Replace on the field codes.
By feild codes I mean the code which I get when I right
click on the {DOCPROPER...} and select Toggle Field codes.

When I try to copy paste the feild code in the "find" part
of the find replace box , the value of the field is being
copied.

Chetak
 
C

Charles Kenyon

You can if you display field codes as suggested. Try Alt-F9 instead of
Shift-F9.
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
C

chetak

Tried Alt-F9 but did not work, When I copy the expanded
DOCPROPERTY the value of that DOCPROPERTY is copied. So
when I paste it what is pasted is its value and not the
{DOCPROPERTY ...}.
 
J

Jezebel

Perhaps you haven't looked at all the options in Find > Special. Display
field codes and search for ^d to find any field, or ^d DOCPROPERTY to find
docproperty fields. (Truly, it does work!) It might also help you to read
Help on the difference between field codes and field results, which seems to
be at the heart of the confusion.

Alternatively, work in VBA and iterate the document's fields collection.
 
C

chetak

I am unable to do find replace on feild codes . When I try
to do a find replace on the replaced text - the
replacement always happens in upper case even though the
text given in the replace box is in lower case.

I am clueless on how to proceed. There are a lot of feild
codes if I got to search and replace them manually.

cheers
Chetak
 
J

Jezebel

Persevere. It does work, as long as you don't start with an expectation of
failure.

Experiment with the 'Match case' checkbox to work out how to deal with your
uppercase/lowercase problem (which has nothing to do with field codes).
 
G

Guest

In an RTF file, the custom properties have the syntax:
{\*\userprops {\propname PropertyName}\proptype30
{\staticval PropertyValue}

PropertyName is the name of the custom property
("sys_name" in your example) and PropertyValue is the
value you wish to replace (replaceThisLater).

Your script could open the file as text, look for this one
value, and replace it once per file. Any printings
(assuming "Update fields" is checked on the print dialog)
will update the entire document. "Update fields" should
ALWAYS be checked, as it is the only RELIABLE way to
update properties in headers and/or footers and/or text
boxes. (Neither F9 not ALT-F9 will reliably update
headers, footers, or text boxes.)

In a Word file, the format is:
DOCPROPERTY "PropertyName" \* MERGEFORMAT PropertyValue

Your script could open the file as text, look for this one
value, and replace it once per file.

Larry Randall
Certified Word Expert
 
C

Chetak

Thank you so much. These words made all the difference !!
Your script could open the file as text, look for this one
value, and replace it once per file.

What I had in my mind was to replace every place a
DOCPROPERTY was defined in the document with a tag like
this <search_for_this> and then do the search replace on
that tag.

Doh! I didn't even think that there should be a central
place where I can do the changes which will be reflected
in all the places the userprop occurs.

So far so good , as far as RTF format goes.

However in a word file , there are multiple occurences of
the below line in a document.

^S DOCPROPERTY Sys_Name MERGEFORMAT ^TKonica Repeater
System^U

in the rtf file the userprop occurs only once. So can the
changes be done in a doc format ?

If I do any changes to the value in the word document , it
does not open until I undo the changes.

Originally, all my documents were in word doc format.
Later it was decided that we go in for rtf format because
it is in ascii format and search replace can be done
throug a script in the unix environment. I notice that
when I save the word documents in rtf format the size of
the document increases . Is it a wise decision to replace
the word format to RTF ?

As of now I am unable to do the change in properties at a
central place by opening a word doc in text format.

Larry Randal,jezebel and Charles kenyon thanks for your
help.

cheers
chetak
 

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