Re: Excel problems switching between documents
Re: Excel problems switching between documents
- Subject: Re: Excel problems switching between documents
- From: Stan Cleveland <email@hidden>
- Date: Sat, 28 Apr 2007 11:57:52 -0700
- Thread-topic: Excel problems switching between documents
Title: Re: Excel problems switching between documents
On 4/27/07 6:05 PM, Max Bonilla wrote:
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?
Hmmm. I hadn’t realized that activate , which makes Excel the frontmost app, was needed. I guess I’ve done it without realizing it doesn’t work otherwise. I’m glad to know that!
As for activating a sheet, my code samples were tiny snippets and didn’t show the larger context. Here they are again with the needed tell statements to Excel and the workbook:
tell application "Microsoft Excel"
tell workbook "FUSMay3CostAnalysis(3).xls"
activate object sheet sheetName
end tell
end tell
tell application "Microsoft Excel"
activate object sheet 1 of workbook "FUSMay3CostAnalysis(3).xls"
end tell
tell application "Microsoft Excel"
tell sheet 1 of workbook "FUSMay3CostAnalysis(3).xls"
activate object
end tell
end tell
Sorry for the omission, but since your code samples included the full context, I assumed you would see that it was required.
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