Find Insertion Point
Find Insertion Point
- Subject: Find Insertion Point
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 14 Dec 2000 19:46:30 -0800
Does anyone know if it's possible to get the "coordinates" of the insertion
point in an MS Word document? If you know a way in some other app that
supports the Text Suite, I'll give it a go here. I want to find a location
that way that I can later use to insert text at that location.
What I've come up with so far is this: if I select a word or a line or
whatever in a document, and then ask for
set theChunk to selection
I get a result of this type:
--text from character 1 to character 4 of paragraph 16 of document "PB
HM Hard Disk:Documents:!Form Letter"
which is rather useful. (You have to say 'contents of selection' or
'contents of theChunk' in Word to get the actual text selected. I like
that.)
I can then say:
select text from character 1 to character 6 of paragraph 16 of window 1
to change the selection. It doesn't work with 'text 1 thru 6' - only with
this verbose 'text from character 1 to character 6'. (You can't get the
class of it either.)
Unfortunately, if you select just white space, or nothing, it errors: 'Can't
get selection'. It _will_ still get
contents of selection
-- " " [ or ""]
And I've discovered that it is possible to set the insertion point wherever
you want in the document:
select text from insertion point 1 to insertion point 1 of paragraph 16
of window 1
will put the flashing insertion point right where I want it. But
unfortunately, it doesn't seem to "know" this syntax when you ask it for the
selection of a flashing insertion point.
I will probably have to ask the users to type in a placeholder word and
select it before running the script. But I'd prefer to tell them just to put
the insertion point where they want it before running the script and let the
script find the location and put it into a script property. It will be
needed many times, not just once, but I don't want the user to have to do
this more than just the once on set-up.
Many thanks for any suggestions.
--
Paul Berkowitz