in Excel 2011 a simple routine renamed a worksheet.
[AppleScript]
tell application “Microsoft Excel”
set name of active sheet to “First”
end tell
[/AppleScript]
Having switched to Office 365 that no longer works
It throws error 10006 and I cannot find anything to fix it. Using “Worksheet” and a number like this works.
[AppleScript]
tell application “Microsoft Excel”
set name of worksheet 1 to “First”
end tell
[/AppleScript]
But that requires you know the number of the worksheet whose name you want to change. I have a work around that solves the issue but it is incredibly clumsy.
[AppleScript]
tell application “Microsoft Excel”
set Allsheets to count every sheet of active workbook
set ActName to name of active sheet
set x to 1
repeat Allsheets times
set Tname to name of sheet x
if Tname = ActName then
exit repeat
end if
set x to x + 1
end repeat
set name of worksheet x to “First”
end tell
[/AppleScript]
I was hoping that either I am missing something or some one has a better solution.
Thanks