2

I have long notes that I have to put on the map. My method is to add the notes to the attribute table and display them as labels. I'm having a hard time writing a label expression that parses the sentences so that every 5 words show up on a new line.

This solution I found on the internet only parses the label into two lines, I can't figure out how to make it work for multiple lines:

left([Labels_for] ,instr(50, [Labels_for] ," ")) & vbnewline & right([Labels_for] ,len([Labels_for] )-(instr(20, [Labels_for] ," "))) 
  • 1
    Do you have the Maplex labeling extension turned on? That has an option for automatically stacking labels that are too long, no need to write your own code. – Dan C Feb 5 at 18:44
  • Thank you for your reply. I've never tried the Maplex before, so it's useful to know it exists. I turned it on in the data frame properties and it froze/crashed my ArcMap. I will try it on a smaller map next time. – Olak Feb 5 at 19:16
2

Change lable language to python and try:

def FindLabel ( [textfield] ):
    text = [textfield].split()
    n = 5
    text = '\r\n'.join([' '.join(text[i:i+n]) for i in range(0,len(text),n)])
    return text

enter image description here

  • 1
    Thank you, this worked exactly as I wanted! I appreciate your screenshot, the Advanced checkbox is key. – Olak Feb 5 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.