2014-07-22 60 views
0

我正在寫一個小的Applescript,它將帶有一些內容的文本框架添加到InDesign文檔中。我試圖在文本框中指定內容的屬性,但沒有任何規格正在應用,我得到了默認值。這些事件不會引發任何錯誤,所以我有點失落。InDesign Applescript使文本框架具有屬性

任何幫助,將不勝感激。

這是我有:

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 

末告訴

+1

文字框架沒有文字屬性。試着針對它的'texts'屬性(這是一個複數形式,所以你可能需要'第一個文本'或者任何相當於Javascript的''textframe.texts [0]'的東西)。 – usr2564301

回答

0

我所做的第一個變化是在你的幾何邊界...

幾何邊界:{50,100, 300,400}

我將它改爲...

幾何邊界:{ 「50分」, 「100分」, 「300分」, 「400分」}

注意,我指定測量單元,由引號所包圍。這很重要,因爲您可能無法始終預測文檔設置的標尺單位。

此外,正如上面的註釋中所述,您試圖將屬性應用於文本框架,它不理解。相反,您需要將它們應用於文本框架的故事。下面的全部工作示例...

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 
+0

非常感謝您對幾何邊界的瞭解。 – MonkeyCMonkeyDo

0

我設法解決它通過定位文本框通過。

   tell xFrame1 
        tell every line 
         set applied font to "Arial" 
         set point size to 10 
        end tell 
       end tell 
0

我剛剛有一個類似的問題,我意識到這可能是最乾淨的方法(除了應用單獨的段落樣式)。希望未來能夠幫助別人。

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 

注意,我不得不告訴頁面,以及 - 我的問題,我在文檔中的所有頁面不得不周期,並把每個頁面上的文本。

相關問題