Re: Excel problems switching between documents
Re: Excel problems switching between documents
- Subject: Re: Excel problems switching between documents
- From: Max Bonilla <email@hidden>
- Date: Fri, 27 Apr 2007 21:05:09 -0400
- Thread-topic: Excel problems switching between documents
Title: Re: Excel problems switching between documents
Hell everyone,
After various attempts at activating the window following Stan’s instructions (thanks, Stan!), the spreadsheet neither moves to the front, nor the script retrieves information correctly. I then tried using IU Browser (just to test through a different angle), and, strangely, Excel would not activate the window, either.
After more testing, I noticed that this would not work (but would not generate an error),
tell application "Microsoft Excel"
activate object window "FUSMay3CostAnalysis(3).xls"
end tell
But this would work:
tell application "Microsoft Excel"
activate
activate object window "FUSMay3CostAnalysis(3).xls"
end tell
Attempting the following, however, would generate an error (“Microsoft Excel got an error: sheet "FUSMay3CostAnalysis(3).xls" doesn't understand the activate object message.”):
tell application "Microsoft Excel"
activate
activate object sheet "FUSMay3CostAnalysis(3).xls"
end tell
So using the double activate seems to do the trick as long as “window” is used instead of “sheet.” Is this a bug?
Max
From: Stan Cleveland <email@hidden>
Date: Fri, 27 Apr 2007 14:13:17 -0700
To: "email@hidden" <email@hidden>
Conversation: Excel problems switching between documents
Subject: Re: Excel problems switching between documents
On 4/27/07 12:22 PM, Max Bonilla wrote:
I’ve converted an Excel X script to Excel 2004 to be able to compare information across two large spreadsheets. For some reason despite my trying to call the spreadsheet (activate), Excel reads the front-most window without regard to my references.
<snip>
In either case, I get erratic results. Sometimes the script reads the right spreadsheet. Other times it does not. The script is never able to move one window to the front (activate). Of course, I’m not interested in bringing the window to the front. What I want is to extract the information from the correct spreadsheet and be sure that I’m getting the expected result (each of the two spreadsheets has over 4600 cells). I also tried referring to the workbook alternatively as window or document, but nothing changed.
I would appreciate some insight.
Use the command activate object, rather than just activate. You also can use sheet, rather than worksheet.
Like this:
activate object sheet sheetName
Or:
activate object sheet 1
Or:
tell sheet 1
activate object
end tell
HTH,
Stan C.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden