I am about to upgrade / update from Office for Mac 2011 to Office for Mac 2016…I have written a number of scripts that involve Excel for Mac 2011…I would like to know before upgrading / updating whether I will encounter any issues or problems in running my scripts after the upgrade / update…if it either helps or is necessary information i) the scripts that I have written use Excel for “reporting” the output / results of scripts run on Contacts, Finder, etc. and ii) the following sub-script is a good example and uses Excel to list / report all the duplicate contacts in Contacts:
tell application "Microsoft Excel"
open
-- Get current date in YYYYMMDD format
set currentDate to current date
set dateFunction to load script POSIX file "/Users/JoelC/Documents/Apple/Scripts/Utilities/20141227_script to convert a date in seconds to a date in yyyymmdd.scpt" as alias
set dateReturned to dateYYYYMMDD(currentDate) of dateFunction
set currentDateYYYYMMDD to dateReturned
-- Make and name a new workbook
make new workbook
set theBook to the active workbook
set theSheet to the active sheet of the theBook
-- Move the workbook to the centre and forefront of the screen
tell application "Moom"
open
arrange windows according to snapshot named "Align Microsoft Excel"
end tell
-- Set the magniifcation / zoom percentage
set zoom of the active window to 100
-- Set the column widths in the new workbook for readability
set column width of the first column of theSheet to 3
set column width of the second column of theSheet to 5
set column width of the third column of theSheet to 20
set column width of the fourth column of theSheet to 70
set column width of the fifth column of theSheet to 3
-- Set and format the column heading and titles
set myRangeCells to range ("B2:D2") of theSheet
set weight of (get border of myRangeCells which border edge top) to border weight thick
set borderWeightLog to get weight of (get border of myRangeCells which border edge top)
set insertedTextTop to "Contact Records Which Appear Two or More Times" as string
set insertedTextBottom to "Selected Contact Source: Work's Exchange Server"
set myRangeTop to range ("B3:B3") of theSheet
set myRangeBottom to range ("B4:B4") of theSheet
set value of myRangeTop to insertedTextTop
set value of myRangeBottom to insertedTextBottom
set myRangeCells to range ("B7:D7") of theSheet
set weight of (get border of myRangeCells which border edge top) to border weight thin
set borderWeightLog to get weight of (get border of myRangeCells which border edge top)
set myRangeCells to range ("B3:B3")
set font size of font object of myRangeCells to 16
set font style of font object of myRangeCells to "Bold"
set fontStyleLog to (get font style of font object of myRangeCells)
set myRangeCells to range ("B4:B4")
set font style of font object of myRangeCells to "Bold"
-- set fontStyleLog to (get font style of font object of myRangeCells)
-- log fontStyleLog
set InsertedTextBottom1 to "Count"
set InsertedtextBottom2 to "Name"
set InsertedTextBottom3 to "Organization"
set myRangeBottom1 to range ("B9:B9") of theSheet
set myRangeBottom2 to range ("C9:C9") of theSheet
set myRangeBottom3 to range ("D9:D9") of theSheet
set value of myRangeTop to insertedTextTop
set value of myRangeBottom1 to InsertedTextBottom1
set value of myRangeBottom2 to InsertedtextBottom2
set value of myRangeBottom3 to InsertedTextBottom3
set myRangeCells to range ("B9:D9") of theSheet
set horizontal alignment of myRangeCells to horizontal align center
set myRangeCells to range ("B11:C100000") of theSheet
set horizontal alignment of myRangeCells to horizontal align center
set myRangeCells to range ("B9:D9")
-- set font size of font object of myRangeCells to 16
set font style of font object of myRangeCells to "Bold"
set myRangeCells to range ("B9:D9") of theSheet
set weight of (get border of myRangeCells which border edge bottom) to border weight thin
set borderWeightLog to get weight of (get border of myRangeCells which border edge bottom)
-- Import myListDuplicates
repeat with i from 1 to count of myListDuplicate
set value of cell ("B" & (10 + i) as string) to i
set value of cell ("C" & (10 + i) as string) to item 6 of item i of myListDuplicate
if item 4 of item i of myListDuplicate < 2 then set item 4 of item i of myListDuplicate to "Organization field is blank"
set value of cell ("D" & (10 + i) as string) to item 4 of item i of myListDuplicate
end repeat
sort range ("C11:D" & (10 + (count of myListDuplicate) as string)) of worksheet theSheet key1 (range "C11" of worksheet theSheet) key2 (range "D11" of worksheet theSheet)
-- Set the name of the spreadsheet to be saved
set userName to do shell script "whoami"
set fileNameSaved to "Macintosh HD:Users:" & userName & ":Desktop:" & currentDateYYYYMMDD & "_contact records which appear two or more times.xls"
-- Save the workbook / spreadsheet
tell theBook
save workbook as theBook filename fileNameSaved overwrite yes
end tell
Thanks for your help,
Joel