Script worked flawlessly in Mavericks but won't work in Yosemite

The script worked flawlessly in Mavericks but upon updating to Yosemite it fails 95% of the time. The fact that it works occasionally makes me think that it is an issue with Yosemite but maybe there is a problem with the script that was triggered by the upgrade.

When functioning properly, the script opens the Excel workbook “Tim.xlsm”, selects the worksheet “Yahoo”, runs a macro which updates the worksheet and then copies the updated information and pastes it into the worksheet “RepliCel”

After updating to Yosemite the script won’t select the Worksheet “Yahoo” and returns the following error message:

error “Microsoft Excel got an error: The object you are trying to access does not exist” number -1728 from worksheet “Yahoo”

Along with the error message the portion of script [select worksheet “Yahoo”] is highlighted.

Script is as follows:

[tell application “Finder”
activate
open document file “Tim.xlsm” of folder “Automated_System” of folder “Investment” of folder “Documents” of folder “timothynye” of folder “Users” of startup disk

tell application "Microsoft Excel"
	activate
	select worksheet "Yahoo"
	tell application "System Events"
		keystroke "p" using {option down, command down}
	end tell
			
	tell worksheet "Yahoo"
		copy range (range "c7:g7")
	end tell
	tell worksheet "RepliCel"
		paste special (find range "b$65:b$65536" what "") what paste values
	end tell
			
end tell

end tell]

Any help or insights would be greatly appreciated.

Model: iMac
AppleScript: 2.7 (176)
Browser: Safari 600.1.25
Operating System: Mac OS X (10.8)

Hi,

I recommend to let Excel open the file. The Finder is not needed at all


set aWorkbook to ((path to documents folder as text) & "Investment:Automated_System:Tim.xlsm")

tell application "Microsoft Excel"
	activate
	open file aWorkbook
	select worksheet "Yahoo"
	tell application "System Events"
		keystroke "p" using {option down, command down}
	end tell
	
	tell worksheet "Yahoo"
		copy range (range "c7:g7")
	end tell
	tell worksheet "RepliCel"
		paste special (find range "b$65:b$65536" what "") what paste values
	end tell
	
end tell


Stefan

It works!!! Thank you very much.

Tim

You’re welcome