Applescript和Excel查找值并获取列字母
是否可以从选定的值中检索列字母Applescript和Excel查找值并获取列字母,excel,applescript,Excel,Applescript,是否可以从选定的值中检索列字母 假设我的值位于特定单元格上。如何获取该单元格的列字母?如果您的单元格被选中,则下面的脚本将为您提供行和列编号 tell application "Microsoft Excel" activate tell window 1 set mySelection to range selection set myRow to first row index of mySelection set myCol
假设我的值位于特定单元格上。如何获取该单元格的列字母?如果您的单元格被选中,则下面的脚本将为您提供行和列编号
tell application "Microsoft Excel"
activate
tell window 1
set mySelection to range selection
set myRow to first row index of mySelection
set myCol to first column index of mySelection
log "row=" & myRow & " myCol=" & myCol
end tell
end tell
获得列号后,可以使用ASCII码将其转换为字母(1=“A”,2=“B”,…)。以下是一种获取列号的方法,无需将其从数字转换为字母
tell application "Microsoft Excel"
tell window 1
-- this will return a string like "$A$1"
set addr to get address (cell 1 of selection)
-- with default text delimiters, words are {"$", "A", "$", "1"}
set col to word 2 of addr
end tell
end tell
假设我的值位于特定单元格上。我怎样才能得到这个专栏
那个牢房的信
一旦您知道如何:
tell application "Microsoft Excel"
set colLetter to character 2 of (get address active cell)
end tell
-->"D"
如果是第27列(或更高),该怎么办?