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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS WORD Custom Fields

Status
Not open for further replies.

kennycad

Technical User
Jan 26, 2005
52
AU

I have a word document in which i have the standard "filename and path" field within the footer.

I am curious to know if i can create some custom fields that when updated show the following:

if for instance the filename was 1234_H001_P1.doc

Field 1 would show characters starting at 6 thru 4 characters EG H001

I dont know how to program fields however to acheive this in other programs it could be something like

(substr FILENAME 6 4)

Any idea's

Thanks
 
Hi kennycad,

Word fields don't have any string manipulation capabilities.

There is a brute-force field coding workaround you could use to extract a sub-string, but it's not for the faint-hearted. For example, assuming the characters you want are alpha-numeric only, you need a field code like the following just to extract the 6th character from a FILENAME field:
Code:
{QUOTE{SET Data {FILENAME}}
{IF{REF Data }= "?????1*" 1 {IF{REF Data }= "?????2*" 2 {IF{REF Data }= "?????3*" 3 {IF{REF Data }= "?????4*" 4 {IF{REF Data }= "?????5*" 5 {IF{REF Data }= "?????6*" 6 {IF{REF Data }= "?????7*" 7 {IF{REF Data }= "?????8*" 8 {IF{REF Data }= "?????9*" 9 {IF{REF Data }= "?????0*" 0}}}}}}}}}}
{IF{REF Data }= "?????a*" a {IF{REF Data }= "?????b*" b {IF{REF Data }= "?????c*" c {IF{REF Data }= "?????d*" d {IF{REF Data }= "?????e*" e {IF{REF Data }= "?????f*" f {IF{REF Data }= "?????g*" g {IF{REF Data }= "?????h*" h {IF{REF Data }= "?????i*" i {IF{REF Data }= "?????j*" j {IF{REF Data }= "?????k*" k {IF{REF Data }= "?????l*" l {IF{REF Data }= "?????m*" m {IF{REF Data }= "?????n*" n {IF{REF Data }= "?????o*" o {IF{REF Data }= "?????p*" p {IF{REF Data }= "?????q*" q {IF{REF Data }= "?????r*" r {IF{REF Data }= "?????s*" s {IF{REF Data }= "?????t*" t}}}}}}}}}}}}}}}}}}}}
{IF{REF Data }= "?????u*" u {IF{REF Data }= "?????v*" v {IF{REF Data }= "?????w*" w {IF{REF Data }= "?????x*" x {IF{REF Data }= "?????y*" y {IF{REF Data }= "?????z*" z {IF{REF Data }= "?????A*" A {IF{REF Data }= "?????B*" B {IF{REF Data }= "?????C*" C {IF{REF Data }= "?????D*" D {IF{REF Data }= "?????E*" E {IF{REF Data }= "?????F*" F {IF{REF Data }= "?????G*" G {IF{REF Data }= "?????H*" H {IF{REF Data }= "?????I*" I {IF{REF Data }= "?????J*" J {IF{REF Data }= "?????K*" K {IF{REF Data }= "?????L*" L {IF{REF Data }= "?????M*" M {IF{REF Data }= "?????N*" N}}}}}}}}}}}}}}}}}}}}
{IF{REF Data }= "?????O*" O {IF{REF Data }= "?????P*" P {IF{REF Data }= "?????Q*" Q {IF{REF Data }= "?????R*" R {IF{REF Data }= "?????S*" S {IF{REF Data }= "?????T*" T {IF{REF Data }= "?????U*" U {IF{REF Data }= "?????V*" V {IF{REF Data }= "?????W*" W {IF{REF Data }= "?????X*" X {IF{REF Data }= "?????Y*" Y {IF{REF Data }= "?????Z*" Z}}}}}}}}}}}}}
My recommendation? Use a macro or take a different course.

Cheers

[MS MVP - Word]
 

that is a lot of code.

think i will attempt to put a macro together instead.

the text i wish to modify is located half way down the page. how do i code a macro to select that particular piece of text?

Any ideas.
 
half way down the page" means absolutely nothing to Word. Zip.

A macro do what, exactly? What, precisely, do you want a macro to do?

If you want to action a chunk of text in Word, the best route is to bookmark that chunk. You can do all the string manipulations you want with bookmark content.

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top