【发布时间】:2021-12-31 19:15:14
【问题描述】:
我想使用 Excel 工作簿(.xlsx) 格式在同一文件夹中另存为 Excel 文件,而不覆盖打开的文档
输入文件类型 --> .xls
输出文件类型 --> .xlsx
告诉应用程序“Finder”
set theWorkbookFile to (choose file with prompt "Select Excel file to process:" of type {"xls", "xlsx"} without invisibles)
set theWorkbookPath to theWorkbookFile as Unicode text
tell application "Microsoft Excel"
activate
open theWorkbookFile
set myBorders to {border top, border bottom, border left, border right}
tell active workbook to tell active sheet
tell used range to set {rowsCount, columnsCount} to {count of rows, count of columns}
repeat with rowValue from 1 to rowsCount
set theCell to cell ("A1" & ":K" & rowValue)
repeat with i from 1 to 4
set theBorder to get border theCell which border (item i of myBorders)
set weight of theBorder to border weight thin
end repeat
end repeat
repeat with rowValueColor from 1 to rowsCount
tell interior object of range ("B1" & ":B" & rowValueColor) of active sheet
set color to {255, 242, 204}
end tell
tell interior object of range ("D1" & ":D" & rowValueColor) of active sheet
set color to {255, 242, 204}
end tell
tell interior object of range ("H1" & ":H" & rowValueColor) of active sheet
set color to {255, 242, 204}
end tell
tell interior object of range ("I1" & ":I" & rowValueColor) of active sheet
set color to {255, 242, 204}
end tell
end repeat
(*
tell application "System Events"
keystroke "s" using {shift down, command down} -- shift-command-left
end tell
*)
end tell
end tell
说完
【问题讨论】:
-
为什么选择 Applescript? Excel有vba。可以用 Numbers 理解 Applescript……
-
@SolarMike 感谢您的建议,但我正在尝试与另一个脚本集成。
标签: excel applescript excel-2016 script keystroke