Mike Volpe
Mike Volpe

Reputation: 23

Getting contents of indesign text frame through applescript

I am trying to form an applescript that will read the contents of one text frame in indesign and if that frame contains a character "/" then it will move another text frame. I figured out how to make the other text frame move, I cannot figure out a way to make applescript "read" what is in the first text frame and search for a character. Here is what I have so far...

tell application "Adobe InDesign CS6"
    tell active document

        set horizontal measurement units of view preferences to inches
        set vertical measurement units of view preferences to inches
        repeat with x from 1 to count pages
            set ThisPage to page x

            tell ThisPage
                if (get text frames whose name of applied object style is "Box1") contains character "/" then
                    move (get text frames whose name of applied object style is "Box2") by {-1.245, 0} --relative move x, y 
                end if
            end tell
        end repeat
    end tell
end tell

I either get no error but it won't do anything or else it gives me compiler errors. Please help! Thank you!

Upvotes: 0

Views: 888

Answers (1)

user1754036
user1754036

Reputation: 544

Try this for your "if" test

if exists (text frames whose (name of applied object style is "Box1" and contents contains "/"))

Upvotes: 2

Related Questions