0

I am writing a small Applescript that adds a text frame with some content to an InDesign doc. I am trying to specify the properties of the content in the text box but none of the specs are being applied and I am getting the default. The events are not throwing any errors so I am a bit lost.

Any help would be appreciated.

This is what I have:

tell application "Adobe InDesign CC 2014"
activate
tell active document
    set xFrame1 to make text frame with properties {justification:center align, point size:5, font:"Arial", geometric bounds:{50, 100, 300, 400}}
    set contents of xFrame1 to "Please work"
end tell

end tell

MonkeyCMonkeyDo
  • 73
  • 2
  • 11
  • 1
    Text frames do not have text properties. Try targeting its `texts` property for that (it's a plural, so you probably need `first text` or whatever the AS equivalent of Javascript's `textframe.texts[0]` is). – Jongware Jul 22 '14 at 20:41

3 Answers3

0

The first change I made was in your geometric bounds...

geometric bounds:{50, 100, 300, 400}

I changed it to...

geometric bounds:{"50 pts", "100 pts", "300 pts", "400 pts"}

Notice that I am specifying the measurement units, surrounded by quotes. This is important as you may not always be able to predict what ruler unit the document is set to.

Also, as stated in the comment above, you were trying to apply properties to the text frame that it doesn't understand. Instead you need to apply them to the story of the text frame. Full working example below...

tell application "Adobe InDesign CC 2014"

    activate -- in this instance, activate is optional and personally I don't usually use it unless required by the routine I'm using.
    tell document 1

         set myText to "Please work!"
         set xFrame1 to make text frame at page 1 of spread 1 with properties {geometric bounds:{"50 pts", "100 pts", "300 pts", "400 pts"}, contents:myText}

         set theStory to parent story of contents of xFrame1
         set properties of theStory to {justification:center align, point size:5, applied font:"Arial"}

    end tell
end tell
ThrowBackDewd
  • 1,737
  • 2
  • 13
  • 16
0

I managed to solve it by targeting the text frame via.

                tell xFrame1
                    tell every line
                        set applied font to "Arial"
                        set point size to 10
                    end tell
                end tell
MonkeyCMonkeyDo
  • 73
  • 2
  • 11
0

I just had a similar problem, and I realised this might be the cleanest approach (except applying a separate paragraph style). Hope that might help someone in the future.

tell application "Adobe InDesign CC 2014"
    activate
    tell active document
        tell page 1
            set xFrame1 to make text frame with properties {geometric bounds:{50, 100, 300, 400}}
            set contents of xFrame1 to "Please work"
            tell first text of xFrame1
                set applied font to "Arial"
                set point size to 5
                set justification to center align
            end tell
        end tell
    end tell
end tell

Note that I had to tell the page as well - for my problem, I had to cycle through all pages in the document and place a text on each page.

Arthur B
  • 1
  • 1