S
spaschke
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Power PC In my applescript, I need to find out if the user has put the cursor in a field at the time the script is run.
There is no inField function and I can't seem to get a (start of / end of) text range of a field relative to the start of the document, for each field when looping through all the fields.
I realize that text ranges contain fields. This makes it confusing that I am trying to find a text range or selection object that may be in a field.
Here is a little script I was testing:
tell application "Microsoft Word"
repeat with fieldnum from 1 to fieldcnt
set show codes of field fieldnum to true
set myrange to content of field code of field fieldnum of active document
if ((start of myrange) > thisRange) and (thisRange > end of myrange) then
display dialog "in field " & fieldnum
else if (start of myrange > thisRange) and (thisRange < end of myrange) then
display dialog "after field " & fieldnum
else if (start of myrange < thisRange) then
display dialog "before field " & fieldnum
else
display dialog "unknown"
end if
--display dialog "start " & (start of myrange) as text
--display dialog "end " & end of myrange as text
end repeat
end tell
Also, has anyone gotten the command "offset" to work from within a tell application "Microsoft Word" section? It is in the dictionary, but always returns an access denied (or something similar) error.
Thanks,
Steve
There is no inField function and I can't seem to get a (start of / end of) text range of a field relative to the start of the document, for each field when looping through all the fields.
I realize that text ranges contain fields. This makes it confusing that I am trying to find a text range or selection object that may be in a field.
Here is a little script I was testing:
tell application "Microsoft Word"
repeat with fieldnum from 1 to fieldcnt
set show codes of field fieldnum to true
set myrange to content of field code of field fieldnum of active document
if ((start of myrange) > thisRange) and (thisRange > end of myrange) then
display dialog "in field " & fieldnum
else if (start of myrange > thisRange) and (thisRange < end of myrange) then
display dialog "after field " & fieldnum
else if (start of myrange < thisRange) then
display dialog "before field " & fieldnum
else
display dialog "unknown"
end if
--display dialog "start " & (start of myrange) as text
--display dialog "end " & end of myrange as text
end repeat
end tell
Also, has anyone gotten the command "offset" to work from within a tell application "Microsoft Word" section? It is in the dictionary, but always returns an access denied (or something similar) error.
Thanks,
Steve