Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word - Docproperty Field Question 2

Status
Not open for further replies.

toonaway

IS-IT--Management
Jun 22, 2004
16
GB
Hi,

I have built some templates used in our SharePoint site. They are Word 2003 format.

I have inserted some docproperty fields to populate some of the server-based data into the document.

I have one field however, that I would like to include all of the text before the ","

For example, the docproperty field returns:

Marketing Department, London

Is there a way of truncating the field to only show the text before the comma? - so that I only see:

Marketing Department

I have constraints in that I can't fix the data at source and can't use macros.

Is there a field code switch or other means of achieving this?

Many thanks for any help !

Toonaway
 
If this is accurate:

"I have constraints in that I can't fix the data at source and can't use macros.

Is there a field code switch or other means of achieving this? "

then, no. A DocProperty has a value. That is its value. If its value is the string "Marketing Department, London"...then that IS its value. So if you are using the actual DOCPROPERTY itself, then that is its value.

There are no field switches to do this.

Can you use another field, get the VALUE of the DocProperty you want, do string manipulation of that value, and come up with "Marketing Department"....yes. However, as you can not use macros, that option is not available for you.

However, hopefully macropod will read this. He is the field guru, so if there is a way to do that kind of string manipulation within a docproperty field, he may be able to offer a solution.

Gerry
 
Hi Toonaway,

Word provides no viable field-based string manipulation tools you can use for parsing text - dates & numbers yes, but text, no.

Your best bet is to use two separate DOCPROPERTY fields. It's always possible to concatenate two such fields via field coding, including conditionally inserting a comma & space if both DOCPROPERTY fields have data.


Cheers
[MS MVP - Word]
 
Thank you for the replies.

I had a feeling this would be the case, but "had to throw it out there" as a last resort.

Thanks for your help,

Toonaway
 
Word provides no viable field-based string manipulation tools you can use for parsing text - dates & numbers yes, but text, no."

That is what I thought (or could find myself), but - shrug - if anyone would know of a way to do string manipulation within a field, macropod would.

I would have to agree that if this is a real requirement it would be best if you could have two DocProperties:

DOCPROPERTY (Location) = "London"
DOCPROPERTY (Department) = "Marketing Department"

Gerry
 
Just thinking...

"I have inserted some docproperty fields to populate some of the server-based data into the document."

If you are putting the value - "Marketing Department, London" - into a DocProperty, that is a string. Can you not do whatever string manipulations at THAT time?

Gerry
 
Hi,

just thinking (not knowing):

- depending on how the rest of the document is processed and on how your users are:
maybe you could put the document property in an ASK-Field as default and let the user do the (string) manipulation

- if you can take data fram a server to Word, can't you take them to Excel first, do the (string) manipulations there and use the results in Word?
This would even allow you to have a history of what was done.

Hope that helps.

Markus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top