Activate Command & Toggle Between Windows using Applescript

Hi All,

I’m having a little problem with the ‘Activate’ command.

I need to toggle between two windows in ‘Microsoft Excel’ and have created an Applescript that will draw data from one Workbook, and paste it into another, and then go back and repeat the process.

I do not want to close the window each time I go through my repeat loop. How do I go through the repeat whilst keeping both windows of both worksheets open, and just activating the one that I need during the repeat??

I have enclosed the kind of language that I am using for the activation process if it helps to tell me where I am wrong??

All the best,

DDHawk.


set myWorkbook to open workbook workbook file name "Macintosh HD:Users:Bang:Documents:MyStuff.xlsx"
	accept all changes active workbook
tell worksheet "Prices" of active workbook
					activate

set myWorkbook1 to open workbook workbook file name "Macintosh HD:Users:Bang:Documents:MyStuff.xlsx"
	accept all changes active workbook
tell worksheet "Houses" of active workbook
					activate

you can use the “activate object” to switch between the two sheets. Looks like you are using the same workbook so…


	activate object worksheet "Houses"
	activate object worksheet "Prices"

if you are wanting to switch between workbooks use:


activate object workbook "MySuff.xlsx"

Thanks, scooter!! Great help!!