Excel: Creating Charts

I have a spreadsheet full of numbers:

DATE CAPACITY FREE SPACE PERCENTAGE FREE
5/23/10 2235.51 547.62 24.50%
5/24/10 2235.51 547.60 24.50%
5/25/10 2235.51 543.30 24.30%

Every day a new row is added by an AppleScript that triggers overnight. That part is working fine (thanks to the help of folks here).

I also want to chart Percentage Free (column D) vs. Date (Column A) over time (i.e. the entire dataset). I want the same AppleScript to update the chart immediately after it adds the new row of data.

I’ve tried Chart Wizard to modify the existing chart, but it has no way to say “grab the data from A and D” and wipes-out the existing chart. Ideally I’d want either: a) I format the chart manually once to get it looking just right, then the script modify that chart without harming the look, or b) be able to script every silly detail so the script can re-generate the chart from scratch every day.

I’ve made a few abortive attempts but I can’t get my head around the syntax. If someone can give me at least a basic example, I might be able to go from there.

THANKS!

Hi Kevin,

Some months ago I wrote an example (a script and an Excel file) to enter data manually into an Excel sheet and update the charts. The script provides also a function to create a new Excel file every 3 months from the template.

You can download the files here

Hope it helps

I’m staring at your script, but not having much luck narrowing it down to the pieces I might need.

I think it is here:

		repeat with i from 1 to idx
			if formula of cell (i + 1) is "" then set formula of cell (i + 1) to item i of nameList
			set value of cell (i + 1) of row cn to item i of valueList
			set ColChar to (ASCII character (65 + i))
			set formula of series 1 of line group 1 of chart of chart object i to ¬
				"=SERIES(" & quote & item i of nameList & quote & ";;Tabelle1!$" & ColChar & "$2:$" & ColChar & "$" & cn & ";1)"
			refresh chart of chart object i
		end repeat

But I’m not seeing how to apply it to my situation. It looks like it rebuilds the chart one data point at a time, or at least checks it that way. But I have 1384 data points and growing. Also not seeing where you are controlling appearance (or is this script appending an existing chart, which is my preference).

Tried running your script, but got an error about a nonexistant object at:

set range_value to value of used range

Some commenting (or commentary) would go a long way to helping me apply your situation to mine.

(Sorry, not trying to be obtuse, usually I can figure-out what snippets of another’s code to use, but yours has me just scratching my head…). Would it help if I posted my current script, despite it’s length?

the line

set formula of series 1 of line group 1.

specifies the range of cells to be considered in the chart
Create a test chart manually in Excel and check the syntax by Right-clicking on the chart object > Datasource
You must probably change .Tabelle1. into your local expression (Sheet1?), I’m running a german version of Excel 2004.

The script should work when EnterDatatest.xls is on desktop

Calvin, try the following which generates a chart dynamically depending on the number of data columns on your sheet ( this has worked even with 90 columns of data…). The script has been modified from the Mactopia Developers section on Excel 2008, subsection Applescript Excel 2004. The original script caused my Excel 2004 to crash so I identified the buggy sections and deleted them. There is one issue though, which I am still working on, and that is regarding scaling; still, I enclose the code because I think it gets you almost there…


tell application “Microsoft Excel”
–dynamically grab the data in columns
tell active sheet

	--Find the headers in the first row:resize range A1 to last used cell of row 1
	set rHeaders to get resize range "A1" column size ¬
		(first column index of (get end (cell ¬
			(count columns) of row 1) ¬
			direction toward the left))
	--Now find the number of data rows and set rData to whole range from row 2
	set rData to get resize range ("A2:A" & first row index ¬
		of (get end range ("A" & (count rows)) direction ¬
		toward the top)) column size (count (columns ¬
		of rHeaders))
	if (count (columns of rHeaders)) = 1 or (count ¬
		(rows of rData)) = 1 then return --  no data, so quit
	
	--Create chart object specifiying its dimensions
	set oChartObj to make new chart object at end ¬
		with properties {top:75, left position:1, height:400.0, width:600.0}
	
	--Now build the Chart within the ChartObject
	tell chart of oChartObj
		--::Define the Chart type..here we have two alternatives, more exists
		--set chart type to xy scatter smooth -- define chart type
		set chart type to line stacked
		
		-- add each series
		repeat with i from 2 to (count (columns of rHeaders))
			set newSeries to make new series at end ¬
				with properties {series values:¬
				(column i of rData), xvalues:¬
				(column 1 of rData), name:¬
				(value of cell i of rHeaders)}
			--  need to specify _value_ (no default property)                                   
		end repeat
		
		--'Add Titles and Format Chart and Axes
		set has title to true
		tell its chart title -- needs 'its !!
			set caption to "My XY Scatter Chart"
			tell font object
				set name to "Calibri"
				set font size to 16
				set bold to true
			end tell
		end tell
		
		set categoryAxis to get axis axis type category axis ¬
			which axis primary axis
		tell categoryAxis
			--set has title to true
			set has title to false
			try
				tell its axis title -- needs 'its' !!
					set caption to "X Values"
					tell font object
						set name to "Arial"
						set font size to 10
						set bold to true
					end tell
				end tell
			end try
		end tell
		
		set valueAxis to get axis axis type value axis ¬
			which axis primary axis
		tell valueAxis
			--set has title to true
			set has title to false
			try
				tell its axis title -- needs 'its' !!
					set caption to "Y Values"
					tell font object
						set name to "Arial"
						set font size to 10
						set bold to true
					end tell
				end tell
			end try
		end tell
		
		--'Format Plot area
		tell plot area object
			tell its border -- needs its
				set color to {0, 0, 255}
				-- will this work?, if not:
				--set its color index to 5
				set line weight to 1
				set its line style to continuous
				-- no transparency property in AppleScript
				--set transparency to 0
			end tell
			tell its chart fill format object
				set visible to true
				--set fore color to {150, 200, 255} 
				--can't set color
				--set transparency to 0.5
				set foreground scheme color to 1 --<<<original value 23 = pinkie; 5 is sky blue
				set transparency to 0.8 -- the same color
			end tell
		end tell
		
		--format legend : Works but dont need it at the mom. TimMurphy
		
		set has legend to false --can be true or false
		try
			tell legend object
				--set its position to legend position right
				--	set its position to legend position top
				set its position to legend position bottom
				(*
			tell its border -- needs its
				set color to {0, 0, 255}
				-- will this work?, if not:
				--set its color index to 5
				set line weight to 1
				set its line style to continuous
				-- no transparency property in AppleScript
				--set transparency to 0
			end tell
			*)
				tell its chart fill format object
					set visible to true
					--set fore color to {150, 200, 255} 
					--can't 
					--set transparency to 0.5
					set foreground scheme color to 23
					set transparency to 0.8 -- the same color
				end tell
				
				tell its font object
					set name to "Arial"
					set font size to 10
					set its font color index to 5
				end tell
			end tell
		end try
		
	end tell
end tell

end tell
:wink:

A further comment to answer my own point about an issue of scaling. There is no issue of scaling, I just forgot that I had defined the chart as “line stacked”, in the above script; this gave the appearance that there was a scaling issue, but in fact, it was just producing what we had asked for, ie: two lines, stacked.
If you replace the chart type definition statement with “set chart type to xy scatter smooth”, or “set chart type to xy scatter lines”, or even, “set chart type to line chart”, everything will be fine.

Regarding Calvin’s actual point that he wants to chart column “C” series of an “A:D” range, this should now be very straightforward; either hard code it, or adjust the rHeaders and rData logic.

Other adjustments that you could make, are regarding the actual scaling level; in the ‘tell valueAxis’ statement, you could modify it like this: tell valueAxis
–set has title to true
set major unit is auto to true
set maximum scale to 4.0
set minimum scale to 2.0
set has title to false
where you hard code specific max / min scale levels, or alternatively, create a handler to extract the maximum and minimum values in your data. There is just such an example here: http://www.macosxautomation.com/applescript/sbrt/sbrt-03.html

You can create the handler at the bottom of your script, and then call it at the top, after you set rData.
Finally, as a further and final refinement, you can run the entire script by pressing a button on the spreadsheet (Excel 2004 only) which calls the chart creation script using the MacScript() command. Let us know if you need help with this.
Hope this helps…
Tim :cool:

TimMurphy,

Confused again with the repeats…I’ve got a very fixed dataset, and don’t need dynamic “figuring out” of columns, I can hard code that. So I don’t have multiple series, just a simple X-Y line graph (free space on the server over time).

So if I need to make the X-Axis “percentage values” from Column D and the Y-Axis “date values” from Column A, how would I re-write this:

					repeat with i from 2 to (count (columns of rHeaders))
						set newSeries to make new series at end ¬
							with properties {series values:¬
							(column i of rData), xvalues:¬
							(column 1 of rData), name:¬
							(value of cell i of rHeaders)}
						--  need to specify _value_ (no default property)                                   
					end repeat

Once I can get that nailed down I can start testing with my spreadsheet, as I think I figured out how to modify the rest of your script for my needs.

THANKS!

No problem, quite straightforward as you can see below.

Open the entire script, including the three handlers at the end, have a Worksheet open with some data in it starting at “A1” such as:
"DATE " “CAPACITY” “FREE SPACE” “PERCENTAGE FREE” “NODES”
5/23/10 2235.51 1119.693285 49.91% 70.72085723
5/24/10 2235.51 1396.145357 37.55% 2.619078576
5/25/10 2235.51 490.0714946 78.08% 18.24029273
5/25/11 2236.51 1448.154329 35.25% 72.23326657 etc. etc.

Note that in the first line of the script you need to enter the title of the specific column you want, say “PERCENTAGE FREE”, and a chart will be created, with the value axis on the right ( my preference) and with a maximum and minimum scale adjusted to the max and min values in your data


–::HardCoded Input, we want to chart ONLY the data in the column that corresponds to this header label “5yr Br”
set ourRequiredDataByHeaderValue to “NODES”

–:: Start of Excel Chart Creation
tell application “Microsoft Excel”
–dynamically grab the data in columns
tell active sheet
–::Find the headers in the first row:resize range A1 to last used cell of row 1
set rHeaders to get resize range “A1” column size (first column index of (get end (cell (count columns) of row 1) direction toward the left))
set rHeaderValues to value of rHeaders --pass the values from a range reference to a list

	--::Now find the number of data rows and set rData to whole range from row 2
	set rData to get resize range ("A2:A" & first row index of (get end range ("A" & (count rows)) direction toward the top)) column size (count (columns of rHeaders))
	--note: rData returns a range reference
	
	--::Check that you have some data to chart
	if (count (columns of rHeaders)) = 1 or (count (rows of rData)) = 1 then return --  no data, so quit
	
	--::Create chart object specifiying its dimensions
	set oChartObj to make new chart object at end ¬
		with properties {top:75, left position:1, height:400.0, width:500.0}
	
	--::Now build the Chart within the ChartObject
	tell chart of oChartObj
		--::Define the Chart type..here we go for a line chart
		set chart type to line chart
		
		-- add each series
		set lowValue to {}
		--Define the position of our Required Data By Header Value within the list of Headers
		set ourRequiredColumn to my list_position(ourRequiredDataByHeaderValue, item 1 of (rHeaderValues)) --rHeaderValues is a list of a list
		--	returns an integer value eg ourRequiredColumn --4
		
		repeat with i from ourRequiredColumn to ourRequiredColumn
			
			set newSeries to make new series at end ¬
				with properties {series values:¬
				(column i of rData), xvalues:¬
				(column 1 of rData), name:¬
				(value of cell i of rHeaders)}
			--  need to specify _value_ (no default property)           
			--::To check the high and low values in our data range for scaling purposes
			set theDataRange to value of column i of rData
			set theRangeHigh to my highest_number(theDataRange)
			set theRangeLow to my lowest_number(theDataRange)
			
			--	copy theRangeHigh to the end of highValue
			copy theRangeLow to the end of lowValue
			
		end repeat
		
		set myScaleMax to theRangeHigh
		set myScaleMin to my lowest_number(lowValue)
		
		--::Add Titles and Format Chart and Axes
		set has title to true
		tell its chart title -- needs 'its !!
			set caption to "Chart of column header you defined in line 1 of this script.."
			tell font object
				set name to "Calibri"
				set font size to 16
				set bold to true
			end tell
		end tell
		
		set categoryAxis to get axis axis type category axis ¬
			which axis primary axis
		tell categoryAxis
			set has title to true
			--set has title to false
			try
				set crosses at to maximum scale
			end try
			try
				tell its axis title -- needs 'its' !!
					set caption to "X Values"
					tell font object
						set name to "Arial"
						set font size to 10
						set bold to true
					end tell
				end tell
			end try
		end tell
		
		set valueAxis to get axis axis type value axis ¬
			which axis primary axis
		tell valueAxis
			--set has title to true
			set major unit is auto to true -- or false
			set major tick mark to tick mark none --
			(*options are:tick mark cross / tick mark inside / tick mark none / tick mark outside*)
			set minor tick mark to tick mark none
			set tick label position to tick label position high
			(*this places value labels (ie. the scale) outside the chart*)
			(*options are: tick label position high/tick label position low/tick label position next to axis/tick label position none*)
			set maximum scale to myScaleMax as real
			set minimum scale to myScaleMin as real
			set has title to false
			try
				tell its axis title -- needs 'its' !!
					set caption to "Y Values"
					tell font object
						set name to "Arial"
						set font size to 10
						set bold to true
					end tell
				end tell
			end try
		end tell
		
		
		--::Format Plot area
		tell plot area object
			tell its border -- needs its
				set color to {0, 0, 255}
				-- will this work?, if not:
				--set its color index to 5
				set line weight to 1
				set its line style to continuous
				-- no transparency property in AppleScript
				--set transparency to 0
			end tell
			tell its chart fill format object
				set visible to true
				--set fore color to {150, 200, 255} 
				--can't set color
				--set transparency to 0.5
				set foreground scheme color to 1 --<<<original value 23 = pinkie; 5 is sky blue
				set transparency to 0.8 -- the same color
			end tell
		end tell
		
		--::Format legend :
		set has legend to false --can be true or false
		try
			tell legend object
				--set its position to legend position right
				--	set its position to legend position top
				set its position to legend position bottom
				tell its chart fill format object
					set visible to true
					--set fore color to {150, 200, 255} 
					--can't 
					--set transparency to 0.5
					set foreground scheme color to 23
					set transparency to 0.8 -- the same color
				end tell
				
				tell its font object
					set name to "Arial"
					set font size to 10
					set its font color index to 5
				end tell
			end tell
		end try
		
	end tell
end tell

end tell
log myScaleMax
log myScaleMin

on list_position(this_item, this_list)
repeat with i from 1 to the count of this_list
if item i of this_list is this_item then return i
end repeat
return 0
end list_position

on highest_number(values_list)
set the high_amount to “”
repeat with i from 1 to the count of the values_list
set this_item to item i of the values_list
set the item_class to the class of this_item
if the item_class is in {integer, real} then
if the high_amount is “” then
set the high_amount to this_item
else if this_item is greater than the high_amount then
set the high_amount to item i of the values_list
end if
else if the item_class is list then
set the high_value to highest_number(this_item) --note recursion
if the the high_value is greater than the high_amount then ¬
set the high_amount to the high_value
end if
end repeat
return the high_amount
end highest_number

on lowest_number(values_list)
set the low_amount to item 1 of values_list
repeat with i from 1 to the count of the values_list
set this_item to item i of the values_list
set the item_class to the class of this_item
if the item_class is in {integer, real} then
if the low_amount is “” then
set the low_amount to this_item
else if this_item < the low_amount then
set the low_amount to item i of the values_list
end if
else if the item_class is list then
set the low_value to lowest_number(this_item) --note recursion
if the the low_value < the low_amount then ¬
set the low_amount to the low_value
end if
end repeat
return the low_amount
end lowest_number


Let us know if this works for you…You may note that the last two handlers use recursion in their method. I was concerned that a stack overflow could occur after around 273 items in a list, but I have tested the script to 400 row values without any problems. Perhaps other members in the group may want to comment on this…?

Hopelessly lost. I was rather hoping to something more straightfoward, something like this pseudocode:

create chart named “Chart” on sheet “Charting” with X-axis “Date” y-axis “percent” given range “‘Data’!A1:B1200” with {some properties controlling appearance}

Based on the examples above, I’m guessing it’s nowhere near that simple? Really missing the old ExtendSeries command. :frowning:

I tried Chart Wizard, but again I’m in the dark on why it isn’t working. Probably the fact that the chart is on a different sheet than the data and I’m not addressing it properly. Or not selecting/activating some “object” properly. Or maybe misusing the range values.

I’ve half a mind to figure out how to get the older Excel to play nice alongside the new Excel (where AppleScript is concerned) as use it as a mule for my old script. Would be easier to understand. :frowning:


But just in case I’m just not explaining enough, or very clearly: the spreadsheet data is on a tab (sheet) called “Data Capture” and the chart is supposed to be generated on a tab (sheet) called “Charting.” Which means the data is on a different tab (sheet) than the chart itself.

Whether the sheet/chart is deleted and re-generated every time data is added, or can somehow be updated-in-place, makes no difference to me.

Here’s the handler…working perfectly in terms of updating the data sheet, but not updating the chart.

on appendSpreadsheet(currentCapacity, currentFreeSpace)
	if gBugFlag is "no" then
		set spreadSheetFile to "Diamond Server Free Space.xlsx"
		set spreadSheetFolder to "DataX: Automation:0100--Diamond Design Monitor:"
		set spreadSheetLocation to (spreadSheetFolder & spreadSheetFile) as text
		set tempFile to "Temp.xls"
		set tempLocation to (spreadSheetFolder & tempFile) as text
		
		
		tell application "Microsoft Excel"
			set reference style to R1C1
			activate
			open file spreadSheetLocation
			--
			--set correct sheet
			activate object worksheet "Data Capture"
			
			--find first empty row
			set currentRow to 1
			set currentColumn to 1
			repeat until (formula of cell currentRow of column currentColumn) is ""
				set currentRow to (currentRow + 1)
				get formula of cell currentRow of column currentColumn
			end repeat
	
			--enter today's date
			activate object cell currentRow of column currentColumn
			set formula of active cell to current date
			
			--move over and enter capacity data
			set currentColumn to (currentColumn + 1)
			activate object cell currentRow of column currentColumn
			set formula of active cell to currentCapacity
			
			--move over one column and enter free space data
			set currentColumn to (currentColumn + 1)
			activate object cell currentRow of column currentColumn
			set formula of active cell to currentFreeSpace
			
			--move over one column and enter percentage free calculation
			set currentColumn to (currentColumn + 1)
			activate object cell currentRow of column currentColumn
			set formula of active cell to ("=C" & currentRow & "/B" & currentRow) as text
			
			--is server space low?
			set gFreePercent to (value of active cell) * 100
			set gFreePercentColor to "6"
			
			if gFreePercent is less than or equal to 20 then
				set highlightRange to ("A" & currentRow & ":D" & currentRow) as text
				
				if gFreePercent is less than or equal to 10 then
					--bold
					set bold of font object of range highlightRange to true
					--red highlight
					tell interior object of range highlightRange
						set color index to 3
						set pattern to pattern solid
					end tell
					--white text
					tell font object of range highlightRange
						set font color index to 2 --set to white
						set bold to true
					end tell
					--matching color index for Finder
					set gFreePercentColor to "2"
				else
					--bold
					set bold of font object of range highlightRange to true
					--yellow highlight
					tell interior object of range highlightRange
						set color index to 6
						set pattern to pattern solid
					end tell
					--matching color index for Finder
					set gFreePercentColor to "3"
				end if
			end if
			
			--build chart from scratch
			--
			activate object chart sheet "Charting"
			--(some code to delete existing chart before starting)
			set chartRange to ("'Data Capture'!$A2:$D$" & currentRow of chart object worksheet "Data Capture") as text
			
			--use Chart Wizard to create basic chart
			chart wizard active chart source chartRange gallery line chart format 4 plot by columns title "Diamond Design Free Space Over Time" category title "DATE" value title "FREE SPACE" without has legend
			
			--reset to data entry sheet
			activate object worksheet "Data Capture"
			
			--
			save active workbook as workbook normal file format in tempLocation
			close active workbook
		end tell
		
		--delete old file, swap and rename temp file
		tell application "Finder"
			delete alias spreadSheetLocation
			update alias spreadSheetFolder
			set name of alias tempLocation to spreadSheetFile
		end tell
	end if
end appendSpreadsheet

Staring at my own code, realizing one problem with the Chart Wizard…I’m feeding it all four columns, probably why it’s not working.

Next chance I get I will put the two key data columns next to each other, moving “D” to the “B” spot, that way I can select a range easier.

So let’s make that assumption, that the range for the chart is really simple, something like:

A2:B1200 on sheet “Data Capture”
which I believe in Excel notation is ‘Data Capture’!A2:B1200

Thanks for your patience!

Well, its quite straightforward to copy and paste the script into Script Editor and run it…Didn’t it work for you? What happened when you tried to run it? I have modelled a worksheet exactly as you indicated and it works perfectly well for me…but if you cant give any more specific feedback on what doesn’t work then there is little else I can suggest.

It might look a bit complicated, but its quite logical. Granted the syntax kind of sucks, but then, Microsoft freely admit in their website that the Excel Chart Object model is complex. I can’t see any way around the problem, unless you want to try scripting Numbers 09?

The script does exactly what you wanted it to - apart from embedding the chart in a different sheet, which you had omitted to mention.:confused:

My apologies for not being clear on this question. I was rather hoping to be taught, not just a finished solution. While it may be “quite straighforward” to you, I guess I don’t understand the Excel object model well enough to grasp it. Which means I can’t “teach myself” as is usually the case.

I have this “thing” about not using code snippets I can’t deconstruct and figure out. I like to figure it out so next time I don’t have to ask for a finished solution, I can do it myself. Learning is half the point. :slight_smile:

To me, what was provided it seems over-complicated when I’ve grown used to the Adobe-style “properties model” and clear nesting of objects.

I decided for now, reluctantly, to abandon the charting until I can find a way to learn the Excel object model, which seems key to understanding charting, and I don’t have the time at the moment (I suspect it’s gonna take alot of it). I can generate jiffy charts manually as the need arises.

Thanks again for your help, and I apologize profusely my lack of clarity and understanding.

Well, I am a bit puzzled that you can’t see the various possibilities open for using either Stefan’s syntax or my own example as a handler attached to your main script. Its really very straightforward. The repeat statements are nothing to do with the Excel model, its basic applescript.
However, if you do want to understand how to generate a chart on excel, from basic principles as you say, you should try and run the attached script.
Step 1: Open a new workbook and enter some data on the range “A1:C14”.
Step 2: Run the script
Step 3: Observe that 2 things happen: a chart object is generated on the worksheet, AND, a chart window is created. Both use the same data and both scripts generate a default chart. Properties to control appearance are ignored so you can focus on the two simple scripts.

The Excel Applescript 2004 Reference states at the top of the third page after the index (page 14): “Note Charts embedded in a worksheet belong to the chart object class, while charts that exist on their own sheets belong to the chart class.” This is key. The first script creates a chart object and populates the data using its object class method; it addresses the ‘series property’ of the ‘chart object’. The second script creates a chart sheet and refers to the data in a different way - through a sheet range reference. Other methods may be used, but I illustrate it this way to make a clear distinction. Things like 'get end of range" are fast ways of identifying the dimensions of the data matrix you want to use, although I am not sure if you understand that, or the use of repeat loops…(?) In any case, play with the two first and then try and understand how you pass a range reference, or iterate (repeat) through columns to select specific data. I hope this does not sound condescending, but as your comments lacked technical feedback, I am unsure of what you know and dont know. I hope these two simple examples help you to understand what you need…

tell application "Microsoft Excel"
	tell worksheet "Sheet1"
		set oChartObj to make new chart object at end with properties {top:75, left position:1, height:400.0, width:500.0}
		tell chart of oChartObj
			set newSeries to make new series at end ¬
				with properties {series values:¬
				(column 3 of range "A2:C14"), xvalues:¬
				(column 1 of range "A2:C14"), name:¬
				(value of cell 3 of range "A1:C1")}
		end tell
		
	end tell
end tell

tell application "Microsoft Excel"
	tell worksheet "Sheet1"
		select (range "A1:C14")
	end tell
	set myChart to make new chart sheet at beginning of active workbook with properties ¬
		{name:"Sales Chart"}
	set theVal to (get properties of active chart) --returns all the chart properties at creation. If you log the properties again at the end of the script and compare with these, they will have changed.
	log theVal1
	
	tell active chart
		set size with window to true
		set chart type to line chart
end tell
	
end tell

Slight ‘Gotcha’ arose on simplifying the first example in my previous post.
In writing this statement, the script won’t fail, but the values range will fail, as the entire sheet column is selected. This statement is wrong:
set newSeries to make new series at end ¬
with properties {series values:¬
(column 3 of range “A2:C14”), xvalues:¬
(column 1 of range “A2:C14”), name:¬
(value of cell 3 of range “A1:C1”)}
and its wrong, because we are addressing range “A2:C14” within a “tell chart of oChartObj” statement, instead of a "tell worksheet “Sheet1"” statement. This causes the range reference to be effectively orphaned.

In trying to simplify the example, I overlooked this. These two new examples work correctly and create a line chart instead of defaulting to the bar chart.

tell application "Microsoft Excel"
	tell worksheet "Sheet1"
		set oChartObj to make new chart object at end with properties {top:75, left position:1, height:400.0, width:500.0}
		tell chart of oChartObj
			set newSeries to make new series at end ¬
				with properties {series values:¬
				(column 3 of range "A2:C14" of worksheet "Sheet1"), xvalues:¬
				(column 1 of range "A2:C14" of worksheet "Sheet1")}
			set chart type to line chart
		end tell
		
	end tell
end tell

or alternatively

tell application "Microsoft Excel"
	tell worksheet "Sheet1"
		set rData to range "A2:C14"
		set oChartObj to make new chart object at end with properties {top:75, left position:1, height:400.0, width:500.0}
		tell chart of oChartObj
			set newSeries to make new series at end ¬
				with properties {series values:¬
				(column 3 of rData), xvalues:¬
				(column 1 of rData)}
			set chart type to line chart
		end tell
		
	end tell
end tell

…sorry about that :stuck_out_tongue_winking_eye:

Friggin’ awesome thread. Better documentation than MS themselves, cheers guys! Been wanting to figure out the tick marks and max/min axis values for a while now.

Here! Here! I concur. This thread rocks!!

Did anyone ever figure out how to set the fore color? Also, I can’t seem to set the border’s line weight either?

Model: MacBook Pro 2.66GHz Intel Core 2 Duo
AppleScript: 2.1.2
Browser: Safari 533.17.8
Operating System: Mac OS X (10.6)