Re: Word Line Numbers
Re: Word Line Numbers
- Subject: Re: Word Line Numbers
- From: Stan Cleveland <email@hidden>
- Date: Thu, 04 Jun 2009 13:10:21 -0700
- Thread-topic: Word Line Numbers
On 6/4/09 10:39 AM, "Thomas Maffucci" wrote:
> on 6/3/09 Stan wrote
>>> Thomas, this should do it:
>>> tell application "Microsoft Word"
>>> set lineNum to get selection >>information selection ¬
>>> information type first character >>line number
>>> --> "17"
>>> end tell
>
> Thanks Stan,
> Script works fine, but my line numbers on the document are numbered
> Continuous rather than Restart each page. Line numbers returned by the
> script are page restart oriented rather than the desired continuous number
> on my document. Have any ideas?
Thomas, there seems to be a bug in Word (I'm running 2008). Theoretically,
the following code should (1) activate line numbering, (2) set line
numbering to continuous, (3) check that they're correctly set (they are),
and (4) get the line number of the 100th paragraph. [Note that I'm using the
'get range information' command rather than the 'get selection information'.
It doesn't matter--both work the same way.]
tell application "Microsoft Word"
tell text object of document 1
set active line of line numbering of page setup of it to true
set restart mode of line numbering of page setup of it ¬
to restart continuous
set {r, a} to {active line, restart mode} of line numbering ¬
of page setup of it
--> {true, restart continuous}
set lineNum to get range information (text object of paragraph 100)
¬
information type first character line number
--> "4" [not what's expected]
end tell
end tell
Word's dictionary lists both 'active line' and 'restart mode' to be gettable
and settable parameters--and they are. If you change them and then ask for
the current settings, Word responds with the expected result. And in the
GUI, the changes actually show up as expected.
The bug is that the 'restart mode' correctly controls what happens in the
GUI, but *not* what happens via script. Getting the line number via script
always uses the 'restart page' mode, regardless of how it's actually set.
My only suggestion, besides filing a bug with Microsoft, is to start by
determining and storing how many lines there are on each page of your
document. Then when you ask for a line number, also get the page number that
the selection is on. Then add the number of lines on the preceding pages to
the line number reported from the page that contains the selection.
You can get the page number of the current selection using one of these two
commands [I'm not clear on the meaning of 'adjusted' in this context]:
get selection information selection information type ¬
active end page number
get selection information selection information type ¬
active end adjusted page number
If needed, you can get the total number of pages in a document with this:
get selection information selection information type ¬
number of pages in document
Good luck, Thomas!
Stan C.
_______________________________________________
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