on run argv
set doc to item 1 of argv
set startParagraph to item 2 of argv as number
set endParagraph to item 3 of argv as number
tell application "Microsoft Word"
activate
tell its document doc
activate
set selectedRange to create range start (start of content of text object of paragraph startParagraph) end (end of content of text object of paragraph endParagraph)
The above code isn’t even selecting the given range tried with (start of paragraph startParagraph)
/ (start of range of paragraph startParagraph)
/ (start of content of paragraph startParagraph)
Nothing did worked the range it selects is only the 1st Paragraph in a document
First, your formatting here is a challenge to root through. Add a linefeed (just type return) before every ‘tell’ and ‘set’. Delete the second ‘activate’. Add a line with three backticks ‘`’ and nothing else immediately above your code and also below. Keep your second paragraph below this code block. Then it should be readable and should compile.
As to the code itself, it would help if you could provide what the script thinks argv
is. It is difficult to troubleshoot without knowing that. The start
and end
parameters of create range require an integer, not a text string and not a real.
This works for me (not on Ventura):
tell application "Microsoft Word"
tell document 1
set p3to to text object of paragraph 3
--> text object of paragraph 3 of document 1 of application "Microsoft Word"
set sc3 to start of content of p3to --> 257
set ec3 to end of content of p3to --> 499
set p3tr to create range start sc3 end ec3
select p3tr
end tell
end tell
1 Like