• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
MS Word: quick way to get styled ranges?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: MS Word: quick way to get styled ranges?
      • From: has <email@hidden>
    • Re: MS Word: quick way to get styled ranges?
      • From: Shane Stanley <email@hidden>
    • Re: MS Word: quick way to get styled ranges?
      • From: Bob Stern <email@hidden>
  • Prev by Date: Re: Problem getting Standard Doc Properties in Word 2011
  • Next by Date: Re: Problem getting Standard Doc Properties in Word 2011
  • Previous by thread: Re: Problem getting Standard Doc Properties in Word 2011
  • Next by thread: Re: MS Word: quick way to get styled ranges?
  • Index(es):
    • Date
    • Thread