Schlagwort-Archive: excel

AppleScript: change column width and row height in excel file

(* excel_columnrow.applescript *)

tell application "Microsoft Excel"
    --set column width and row height
    set row height of range "1:30" to 40 -- points (rows)
    set column width of range "A:Z" to 2 -- characters (columns)

    delay 3

    -- set range to autofit
    tell range "A1:Z30" of active sheet
        repeat with i from 1 to (count columns)
            autofit column i
        end repeat
    end tell
end tell


AppleScript: add comment to cell in excel sheet

(* excel_addcomment.applescript *)

tell application "Microsoft Excel"
    tell range "A10" of active sheet
        set cmt to its Excel comment -- no error if nothing (dummy comment)
        set vis to visible of cmt --get any property , returns missing value if empty
        if vis is missing value then
            set cmt to add comment
        end if
    end tell

    tell cmt
        Excel comment text text "My comment" --overwrites, but omit 'over write'!
        set visible to true
        select its shape object -- to allow editing
    end tell
end tell