0

我有一个 AppleScript,它拒绝在我提供的任何 excel 文件上运行。它也拒绝打开:当我尝试在 AppleScript 编辑器中打开脚本时,系统提示我:

Open Dictionary: Unable to read the dictionary of the application or extension because it is not scriptable.

Mountain Lion 中是否有与 AppleScript 冲突的更新?还有哪些其他错误阻止我运行脚本?

on open excelFiles

set numRows to 0
set numCols to 0
set usedRange to 0

repeat with eachFile in excelFiles
tell application "Microsoft Excel"
set tbook to open workbook workbook file name (eachFile as string)
set tName to name of tbook
set numCols to (count of columns of used range of active sheet)
set numRows to (count of rows of used range of active sheet)

insert into range column 1 of active sheet -- insert column
set lastCell to last cell of used range of active sheet -- get last cell from the used range
set value of range ("A1:A" & first row index of lastCell) of active sheet to tName --set first column's values to the file name

--set lastCell to last cell of used range of active sheet -- get last cell from the used range
--set value of range ("A1:A" & numRows) of active sheet to tName --set first column's values to the file name
--set usedRange to (used range of active sheet)

replace (used range of active sheet) what "," replacement ("^")
replace (used range of active sheet) what "$" replacement (" ")
replace (used range of active sheet) what "°" replacement ("-degrees ")
replace (used range of active sheet) what "©" replacement (" ")
replace (used range of active sheet) what "à" replacement ("a")
replace (used range of active sheet) what "á" replacement ("a")
replace (used range of active sheet) what "â" replacement ("a")
replace (used range of active sheet) what "ã" replacement ("a")
replace (used range of active sheet) what "ä" replacement ("a")
replace (used range of active sheet) what "ç" replacement ("c")
replace (used range of active sheet) what "ć" replacement ("c")
replace (used range of active sheet) what "è" replacement ("e")
replace (used range of active sheet) what "é" replacement ("e")
replace (used range of active sheet) what "ê" replacement ("e")
replace (used range of active sheet) what "ë" replacement ("e")
replace (used range of active sheet) what "ì" replacement ("i")
replace (used range of active sheet) what "í" replacement ("i")
replace (used range of active sheet) what "î" replacement ("i")
replace (used range of active sheet) what "ï" replacement ("i")
replace (used range of active sheet) what "ò" replacement ("o")
replace (used range of active sheet) what "ô" replacement ("o")
replace (used range of active sheet) what "ó" replacement ("o")
replace (used range of active sheet) what "õ" replacement ("o")
replace (used range of active sheet) what "ö" replacement ("o")
replace (used range of active sheet) what "ü" replacement ("u")
replace (used range of active sheet) what "½" replacement (".5")
replace (used range of active sheet) what "¼" replacement (".25")
replace (used range of active sheet) what "¾" replacement (".75")

--display dialog "The used range of this sheet is" & range
--display dialog "The number of rows of this file is " & numRows
--display dialog "The number of collumns of this file is " & numCols

close tbook saving yes

end tell
end repeat
end open
4

1 回答 1

0

尝试告诉捆绑标识符。

tell application id "com.microsoft.Excel"
-- insert your code
end tell
于 2012-09-20T13:12:29.990 回答