2014-11-09 90 views
0

有人可以帮我删除错误吗?AppleScript中缺少值

错误“缺少值不能转换为类型编号”。编号-1700从缺失值到编号

tell application "Numbers" 
    activate 
    open theFile 
    tell the first table of the active sheet of document 1 
     repeat with i from 2 to the count of rows of column "D" 
      set val1 to value of cell i of column "D" 
      set the value of cell i of column "D" to val1 * -1 
     end repeat 
    end tell 
end tell 

谢谢!

回答

1

基本上,当单元格没有任何值时会发生这种情况,因此表中必须有一些空行。最简单的做法是使用一个try块,当你不能将val1乘以-1时,它将忽略所有的错误。

tell application "Numbers" 
    activate 
    open theFile 
    tell the first table of the active sheet of document 1 
     repeat with i from 2 to the count of rows of column "D" 
      set val1 to value of cell i of column "D" 
      try 
       set the value of cell i of column "D" to val1 * -1 
      end try 
     end repeat 
    end tell 
end tell