MS Word: quick way to get styled ranges?
MS Word: quick way to get styled ranges?
- Subject: MS Word: quick way to get styled ranges?
- From: has <email@hidden>
- Date: Tue, 15 Mar 2016 10:11:46 +0000
Hi folks,
Any advice on how to get the positions of styled characters (e.g.
`bold`) in a paragraph of text? e.g. In TextEdit (and Dog knows its text
support is pretty damned rubbish), you'd just say:
tell application "TextEdit"
set {textsList, fontsList} to {every attribute run, font of every
attribute run} of document 1
end tell
and after spinning its wheels a bit it'd give you a list of text
fragments plus a list of the fonts applied to them. But MS Word
scripting is a special hell where any non-trivial query fails silently
and fetching each character property one at a time takes longer than the
heat death of the universe:
set res to {}
tell application "Microsoft Word"
tell text object of active document
repeat with i from 1 to (count every character)
set end of res to {content, bold} of character i
end repeat
end tell
end tell
res --> {{"P", false}, ..., {"W", true}, ...}
Please tell me there's something better than this.
Ta,
has
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden