Open Excel

I have a script that performs calculations in excel and I want it to open excel ask for input and complete the calculation. However I can not get Excel to open from the script I have to open it then run the script. Also I cannot compile the script if Excel is not open.

This is the scrip can anyone suggest how I can open Excel.



tell application “Microsoft Excel”
set wb to make new workbook
set containerList to {}
set containers to return & return & return & return & return
set areas_ to {“Area 1”, 16966, “Area 2”, 23328, “Area 3”, 15905, “Area 4”, 15905, “Area 5”, 10604, “Area 6”, 10604}
set NoAreas to (count areas_)
repeat with X from 1 to NoAreas
set value of cell X in range “B5:C10” to item X of areas_
end repeat
display dialog “Enter % for each Area followed by return” & return & “Area 1” & return & “Area 2” & return & “Area 3” & return & “Area 4” & return & “Area 5” & return & “Area 6” default answer containers buttons {“Cancel”, “Done”}
set valueList to paragraphs of text returned of result
set NoValues to count of items of valueList
repeat with X from 1 to NoValues
set value of cell X in range “D5:D10” to item X of valueList
set ct to “C” & X + 4
set dt to “D” & X + 4
set ft to “F” & X + 4
set formula of cell ft to “=” & ct & “*(” & dt & “/100)”
end repeat
select range “F5:F10”
set number format of selection to “#,##0.00”
set formula of range “F11” to “=sum(F5:F10)”
select range “f11”
set bold of font object of range “F11” of worksheet “sheet1” to true
end tell



tell application "Microsoft Excel"
	set wb to make new workbook

Hi Stefan

I have now tried that and I get an error of the type -10665 returned. I also tired a shell script

do shell script "open -a /Applications/Microsoft\\ Office\\ 2011/Microsoft\\ "

that will open Excel but if I put that as the first line of my script outside of the tell block it opens excel OK but then tells me I have the same error. Tried building a 5 second delay in in case it was running over itself but the same error -10665.

thanks for the suggestion appreciated as always.


The error is very unusual.

I recommend to rebuild launch services database

Hi Stefan

I used Onyx to rebuild the launch services database, restarted my machine etc but still get the same error any more ideas.

I did try a terminal command I found for rebuilding but that did not work and I think it may have been for Leopard. MyOnyx is up to date and I would like to think it handles Mountain Lion Ok.

As its unusual for you I am totally confused.

I also opened terminal and ran this command which I found on line’’

sudo find /System/Library/Frameworks -name lsregister` -kill -seed

that did not help.

It is a machine problem as I ran you command on my lap top and it worked fine. Do you have any other suggestions.

thanks again


Open the

See if there is a dedicated Excel log file there, or look at the all messages, and filter it for Excel.

Maybe some items that is supposed to be there during startup, is either missing, or corrupted.

Try deleting any startup items you may have in Excel, and even your preference files, and see if that works.

Go to an MS Forum to figure out what −10665 really means as this is an Excel error.

If this doesn’t work, do try to reinstall Excel. (Save your license number up front, and the other data, I think you will have to re-register.) Awkward, but I think it will save you time in this case.