Microsoft Excelで、ワークシートに貼り込んだ画像の左上のセルアドレスを求めるAppleScriptです。
AppleScript名:配置されている画像の左上のアドレスを取得してA1形式で返す.scpt |
— – Created by: Takaaki Naganoya – Created on: 2024/12/06 — – Copyright © 2024 Piyomaru Software, All Rights Reserved — tell application "Microsoft Excel" tell active workbook tell active sheet set aPic to picture 1 set tlCell to top left cell of aPic set xCell to first column index of tlCell set yCell to first row index of tlCell set cellAdr to (numberToCell(xCell) of AddressEncoder) & (yCell as string) –> "B5" end tell end tell end tell script AddressEncoder property parent : AppleScript use scripting additions — 数値からセルアドレス(A1形式)への変換 on numberToCell(columnNumber) set columnAddress to "" set tempNumber to columnNumber — 列番号をA-Z形式に変換 repeat while tempNumber > 0 set remainder to (tempNumber – 1) mod 26 set columnAddress to (character (remainder + 1) of "ABCDEFGHIJKLMNOPQRSTUVWXYZ") & columnAddress set tempNumber to (tempNumber – 1) div 26 end repeat — A1形式のアドレスを返す return columnAddress end numberToCell — セルアドレス(A1形式)から数値への変換 on cellToNumber(cellAddress) set columnPart to "" set rowPart to "" — 列部分と行部分を分離 repeat with char in cellAddress if char is in "0123456789" then set rowPart to rowPart & char else set columnPart to columnPart & char end if end repeat — 列部分を数値に変換 set columnNumber to 0 repeat with i from 1 to length of columnPart set char to character i of columnPart using terms from scripting additions ignoring case set columnNumber to columnNumber * 26 + (offset of char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ") end ignoring end using terms from end repeat — 数値を返す return {columnNumber, (rowPart as integer)} end cellToNumber end script |
More from my site
(Visited 1 times, 1 visits today)