tell application "Microsoft Excel"
activate chart object 1
get chart title text of chart object 1
end tell
-- Result: missing value
-- desired result "New Chart"
tell application "Microsoft Excel"
activate object chart object 1 of active sheet
set chart title text of chart title of active chart to "Some Other Title"
end tell
Edit: Congratulations, slashdot - you’re my 500th customer!
I have the following code. Is there an script that can format the text of “Title_2” to font size 10 and “Title_3” to font size 9?
tell application "Microsoft Excel"
set chartTitle to "Title_1\r" & "Title_2\r"& "Title_3"
activate object chart object 1 of active sheet
set chart title text of chart title of active chart to chartTitle
end tell
This should set the font sizes for lines 2 & 3 of the title:
set fontSize to {10, 9}
set chartTitle to "Title_1" & return & "Title_2" & return & "Title_3"
tell application "Microsoft Excel"
activate object chart object 1 of active sheet
set chart title text of chart title of active chart to chartTitle
set r to count chartTitle's paragraph 1
repeat with i from 2 to count chartTitle's paragraphs
set l to r + 2
set r to r + 1 + (count chartTitle's paragraph i)
set font size of font object of characters l thru r of chart title of active chart to fontSize's item (i - 1)
end repeat
end tell
And this slightly modified version should set font sizes for every line:
set fontSize to {12, 10, 9}
set chartTitle to "Title_1" & return & "Title_2" & return & "Title_3"
tell application "Microsoft Excel"
activate object chart object 1 of active sheet
set chart title text of chart title of active chart to chartTitle
set r to -1
repeat with i from 1 to count chartTitle's paragraphs
set l to r + 2
set r to r + 1 + (count chartTitle's paragraph i)
set font size of font object of characters l thru r of chart title of active chart to fontSize's item i
end repeat
end tell