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

Determine Length Of Mail Merge Field

Status
Not open for further replies.

mark1110

Programmer
Apr 20, 2005
85
US
Hi,

I have a mail merge document that gets its information from an excel file. Is there a function in word that will give me the length of the one of the fields, i.e. mm_name? If not, is there a way to treat a phone number (555) 555-1212 as one word so the (555) is not on one line and 555-1212 on another. The user won't delete the space between after the ) or will the user start the phone number on a separate line.

I am currently adding spaces before the phone number and if the mm_name is under 12 characters the letter looks okay, however if it is over 12 characters you something like this:

Jonathon Longname (555) 555-1212.

If not, is there a way when the letter is printed to delete all instances of spaces that 2 or greater and just make them one space?

Thanks,

Mark
 



Hi,

Check out the TRIM & LEN function.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Here is the statement I tried but with no luck:

IF {len({MERGEFIELD FullName}+ {MERGEFIELD FirstName}) > 10 AND len({MERGEFIELD FullName}+ {MERGEFIELD FirstName}) < 19 SPACE(19 - len({MERGEFIELD FullName}+ {MERGEFIELD FirstName})}

I have never tried this in a word document. Am I using the correct syntax?


Mark
 



These functions are VBA functions. This forum is related to VBA code questions.

If you're trying to do something using native MS Word features, you need to post in forum68. Have you looked at Insert Merge Field?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top