2009-01-17 35 views
1

我正在嘗試訪問Applescript中單元格的完整引用。到目前爲止,我已經成功地得到了單元格引用,並使用腳本,如表參考:訪問iWork Numbers中的單元格屬性

tell application "Numbers" 
tell document 1 
repeat with i from 1 to count of sheets 
tell sheet i 
repeat with j from 1 to count of tables 
tell table j 
try 
set currentCell to the first cell of the selection range 
return name of currentCell 
end try 
end tell 
end repeat 
end tell 
end repeat 
end tell 
end tell 

我似乎無法得到相同的結構,爲獲得紙張或文檔的參考工作。我曾嘗試接入小區的性質,我得到這樣的:因此

{column:column "A" of table "Table 1" of sheet "Sheet 1" of document "Untitled" of 
application "Numbers", alignment:center, value:0.0, background color:{59111, 59111, 
59111}, text color:{0, 0, 0}, font size:10.0, vertical alignment:top, name:"A1", 
class:cell, font name:"HelveticaNeue", format:automatic, row:row "1" of table "Table 
1" of sheet "Sheet 1" of document "Untitled" of application "Numbers", text 
wrap:true} 

一個單元格的列屬性似乎包括了完整的參考,但如果我直接通過列屬性訪問參考。 任何人都可以給我一些指導,以瞭解如何使用applescript獲取表單和文檔。

乾杯

伊恩

回答

1

找到了解決辦法,很簡單,只要代碼是正確的順序:

tell application "Numbers" 
tell document 1 
    repeat with i from 1 to count of sheets 
     tell sheet i 
      repeat with j from 1 to count of tables 
       try 
        tell table j 
         set currentCell to the first cell of the selection range 
         set therow to row of currentCell 
         set sheetNumber to i 
        end tell 
       end try 
      end repeat 
     end tell 
    end repeat 
    return name of sheet sheetNumber 
end tell 
end tell 

可以使用類似的代碼來檢查文檔編號