Re: Need help with a Word script
Re: Need help with a Word script
- Subject: Re: Need help with a Word script
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 09 Aug 2009 17:22:46 -0700
- Thread-topic: Need help with a Word script
Title: Re: Need help with a Word script
Word is an extremely sophisticated application - what you refer to as "junk". What Word refers to as the Style of a paragraph (and which you can find in the Formatting Palette) is named - like Normal, Heading 1, Heading 2, Body Text, Envelope, etc., all pre-defined, but which can be modified by the user, or custom Styles create - where literally dozens upon dozens of characteristics are defined, including things like Space Before, Indentation, etc. etc. To get an idea, select the current style in the Formattiing Palette, click and select Modify Style in the popup. Or go to Format menu/Style...
But in AppleScript the 'style' property of a paragraph is just an enumeration that gets you just the name of the style. What you are looking for will almost all be in the 'font object' of the 'text object' of the paragraph or word. (That's how you can get properties like 'bold' of a particular word that might differ from the 'bold' of the paragraph it's in.) The class of the 'font object' property is 'font': check 'font' in the Word Dictionary and you'll see it's got most of the properties you're looking for.: bold, italic, font size, color, etc. etc. and of course, name (name of the font). If you still need more, check 'paragraph format' of the paragraph for things like line spacing.
--
Paul Berkowitz
From: <email@hidden>
Date: Sun, 9 Aug 2009 19:25:48 +0000 (UTC)
To: AppleScript-Users <email@hidden>
Subject: Need help with a Word script
Hi
I'm writing a script to extract format names, style and text from a Word document and package it up into another file sans all the junk Microsoft packs into a word file. I'm able to get the paragraphs and their styles, but can't figure out how to get style ranges within a paragraph. For example say an editor chooses a style for a paragraph and then bolds various words within that paragraph, how would I go about getting these ranges and the style associated with them?
I already tried using the "range" and "text range" keywords but all they return is empty lists. Here's what I have so far
tell application "Microsoft Word"
tell document 1
set paragraphList to paragraphs
set resultList to "<v7.31><e9>" & return
repeat with aPara in paragraphList
tell aPara
set paraStyle to style
set paraText to content of text object
end tell
-- would like to get the bold, italic, pointsize change etc rangesĀ
-- and loop through those as well, but no luck so fat
set resultList to resultList & "@" & paraStyle & ":" & paraText
end repeat
end tell
end tell
Does anyone know how I could get these ranges, or if it's even possible?
Thanks for any help
_______________________________________________
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
_______________________________________________
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