PDA

View Full Version : Split sentence in word



zarthon59
11-14-2011, 01:20 PM
Hello,

I am obviously a newbie with vba... A similar problem has been brought up (I can't put a link; search for Splitting Strings Every X Characters. in this forum), but still I am stuck.

My problem is: I have a word document. I edit subtitles for movies. Each line should be around 120-character long max. I have to split long sentences. I used the script, but it somehow becomes really tricky for a whole document (20 pages)

1: I select sentences between two "return"
2: I split it with the code above
3: I replace the selection with my new split sentences

It should be simple, right? Anybody? Ideas?

macropod
11-14-2011, 02:50 PM
Hi zarthon39,

You may be able to do that with a wildcard Find/Replace, where:
Find = [!^13]{120}
Replace = ^&^p

macropod
11-14-2011, 08:57 PM
A more sophisticated approach would be to use a wildcard Find/Replace, where:
Find = [!^13]{110}[! ]{1,9}[ ]
Replace = ^&^p
With this approach, you'll avoid splitting words. The actual breaks will occur at the first space between the 110th & 120th characters, with the space as the last character on each line.

zarthon59
11-15-2011, 06:07 AM
Brilliant! It works really well :)