Trailing line breaks removed from Word text

I’m using an Applescript to get selected text from Word, because Word’s implementation of the clipboard screws various things up. The Applescript I’m using is:
tell application "Microsoft Word" to return content of text object of selection
I then have KM save the text to a variable.

If the selected text in Word ends with a line break (or multiple line breaks), those line breaks are returned by Applescript. (I can see them in the Result pane of Script Editor.) But when I look at the variable in the KM preferences, Keyboard Maestro has removed them. This only applies to line breaks at the end of the text—breaks in the middle are preserved.

Any ideas? I imagine I could come up with a workaround by replacing the line-break characters in Applescript, but I’d like to know if there’s a less clunky solution.

Have a look to:

1 Like

Yes, unchecking “Trim Results” fixes it! Thanks.

1 Like

I’m using an Applescript to get selected text from Word, because Word’s implementation of the clipboard screws various things up.

I’m curious: What does Word’s clipboard screw up? How can you see the difference between copying in Word and via your AS?