We help IT Professionals succeed at work.

String operations on MSWord text fields?

Member_2_4694817
Member_2_4694817 asked
on
I would like to insert a field into Word 2003 that contains only a substring of a given text field, esp. the filename.
For example if
{ FILENAME MERGEFORMAT }
produces foobarbaz.doc, I rather want the substring of length 3 starting at position 3 (i.e. "bar") to appear
However, functions seem to be restricted to numeric funtions, I think.
So it appears there is no such thing as
{= SUBSTR( { FILENAME MERGEFORMAT }, 3, 3) }
Or is there?
Comment
Watch Question

Retired
Top Expert 2012
Commented:
You are right. There are virtually no string manipulation methods in Word fields. You would have to use VBA in some way to capture the filename, and display a portion of it.

Author

Commented:
*sigh*  I was afraid so.
I've now written a macro that replaces some "INSERT-STUFF-HERE" with the content I need.
This is of course suboptimal in that field update mechanisms etc. don't really work ...