2014-11-09 3 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 
Смежные вопросы