2013-10-25 85 views
0

我有AS正在向Word 2011中的表中寫入數據,我可以獲取該表格的屬性,但是如何複製表格並向活動文檔添加新表格,但是一個不同的名字/ ID? abFile在tell塊之前指定。使用Applescript複製Word表格

tell application "Microsoft Word" 
activate 
open abFile 
set tableProps to get properties of tables of active document 
end tell 

我想是這樣說的:

make new table in active document with tableProps and name "2" 
+0

據我可以告訴字典,MS字表沒有「名稱」屬性。至少不適用於OSX 10.8.5上的Word 2011。此外,我認爲對於任何正確實施的applescript字典,對象id始終**由applescript運行時環境分配,並且只讀爲腳本 –

+0

查看SL中的Word 2011字典我會同意但我怎麼能用相同的屬性創建一個新表,然後讓AS照看ID? – Dan

回答

1

我想的第一件事情是這樣的:

tell application "Microsoft Word" 
    activate 
    open abFile 
    set tableList to tables of active document 
    set firstTable to item 1 of tableList 
    make new table in active document with properties (properties of firstTable) 
end tell 

這確實創建一個新表,但沒有屬性似乎實際上被複制 - 至少行和列的數目是不同的。

你可以嘗試的另一件事情是簡單地複製表:

tell application "Microsoft Word" 
    activate 
    open abFile 
    set tableList to tables of active document 
    set firstTable to item 1 of tableList 
    duplicate item 1 of tableList 
end tell 

這又確實建立了新表,但它的單元格的內容是一樣的原始表。我不確定您是否想要複製屬性,或者是否希望複製單元格內容。

+0

輝煌,謝謝,正是我所需要的。 – Dan

相關問題