MS Excel Applescript - How to Reference & Use the Active Cell

Maybe this is obvious to many/most of you, but it took me a little while to figure it out, and I did NOT find any direct examples of this. So, thought I’d share with all . . .

MS Excel Applescript - How to Reference & Use the Active Cell

Note that one key requirement is that the “Active Cell” can be referenced ONLY from the main Excel Application Object – NOT from “Active Workbook” or “Active Sheet”.


tell application "Microsoft Excel"
	
	set oActiveCell to active cell -- Returns the currently selected cell
	
	tell oActiveCell
		
		set value to "TEST Using Tell Cell"
		set oACFont to font object
		
		tell oACFont
			
			set bold to true
			set font size to 18
			
		end tell -- oACFont
		
	end tell -- oActiveCell
	
end tell

Hey Michael,

Scripting Excel or Word can be a hair-pulling exercise. :cool:

http://forum.keyboardmaestro.com/t/clipboard-formatting-ms-excel/1400/7?u=ccstone

A quick look in the dictionary of Excel reveals that active cell is a property of the class application or class window, which both belong to the class application .