problem referring to object in doc with Applescript

A

almacrae

Version: 2008
Operating System: Mac OS X 10.5 (Leopard)
Processor: intel

I've written what I thought was a relatively simple Applescript to replace a VBA script I'd used for years- the VBA took the currently selected picture (pasted or inserted) and applied some positioning, sizing and formatting to it.
The Applescript works fine for the first picture; the problem occurs when running it on the second picture in the document - it applies the first step in the script to the selected script - but every step thereafter is applied to the first pic.
Here's the script:

tell application "Microsoft Word"
tell front document
set s to (convert to shape (inline picture 1 in selection in active window))
set the width of s to 3.25 * 72
set the left position of s to -252
set the fore color of line format of s to ({0, 0, 0} as RGB color)
set the weight of line format of s to 1
end tell
end tell

Since there may be as many as 40 or 50 pictures inserted in this way, and as the document evolves, I may be inserting pics anywhere in the flow (not at the end), I really don't know how else to refer to the pic - but clearly Word is losing the reference to the selected object as soon as the first step is applied (because it is no longer selected) - so how do I convert the reference to a selection to a stable, persistent reference?

Or is this a bug?

Remember, the VBA script worked for years (decades!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top