Re: Bug in (scripting) Excel.
Re: Bug in (scripting) Excel.
- Subject: Re: Bug in (scripting) Excel.
- From: kai <email@hidden>
- Date: Sun, 28 Sep 2003 16:35:41 +0100
on Sat, 27 Sep 2003 21:52:37 -0700, Paul Berkowitz wrote:
>
On 9/27/03 9:25 PM, Deivy Petrescu wrote:
>
>
> The problem is the command "set ScreenUpdating to false".
>
> As I understand, it means the computer screen is not going to be
>
> refreshed, other than that, all the other commands are fully realized.
[snip]
>
> even if it is not a bug, it is a bad implementation.
>
>
The trick to understanding Excel AppleScript terms is to look up their
>
equivalent in the VBA Help.
>
>
I don't seem to be able to copy and paste from the Help so you'll have to
>
look it up yourself.
Without checking further, I don't know if the information has changed
significantly from Excel 98:
------------------------------------
ScreenUpdating Property
-----------------------
True if screen updating is turned on. Read/write Boolean.
Remarks
-------
Turn screen updating off to speed up your macro code. You won't be able to
see what the macro is doing, but it will run faster.
Remember to set the ScreenUpdating property back to True when your macro
ends (versions of Microsoft Excel earlier than Microsoft Excel 97 and
Microsoft Excel 98 automatically reset this property).
------------------------------------
(I can't select the help text directly either, but selecting 'Copy' from VBA
Help's 'Edit' menu, or pressing command-c, brings up a copy dialog box.)
>
basically, it's designed to run code and calculations
>
faster by _not_ displaying them on the screen. Therefore it does stand to
>
reason that it's going to ignore any commands - like Activate - which
>
specifically relate to screen display, no?
While I can appreciate both points (c'mon kai, get down off the fence!), I
tend to share Deivy's view that Excel should still perform as normal - just
without updating the on-screen representation of events.
To compare Excel X's behaviour with that of my older version, I inserted a
ScreenUpdating/off statement in my test script:
--------------------------------
set xlFold to "Hard Disk:Desktop Folder:Excel Tests:"
set {n1, n2, n3} to {"xlTest1", "xlTest2", "xlTest3"}
tell application "Microsoft Excel"
set ScreenUpdating to false
repeat with w in {n1, n2, n3}
Open (xlFold & w)
end repeat
Activate Window n1
set lastcolumn to Column of (LastCell of Range "A1" Direction xlToRight)
set ScreenUpdating to true
lastcolumn
end tell
--------------------------------
From the Event Log (remember that the first workbook to open, "xlTest1" is
the only one to contain data in column 4 of worksheet 1):
--------------------------------
tell Application "Microsoft Excel"
set ScreenUpdating to false
Open "Hard Disk:Desktop Folder:Excel Tests:xlTest1"
--> Workbook "xlTest1"
Open "Hard Disk:Desktop Folder:Excel Tests:xlTest2"
--> Workbook "xlTest2"
Open "Hard Disk:Desktop Folder:Excel Tests:xlTest3"
--> Workbook "xlTest3"
Activate Window "xlTest1"
--> true
LastCell Range "A1" Direction xlToRight
--> Range "R1C4" of Worksheet "Sheet1" of Workbook "xlTest1"
get Column of Range "R1C4" of Worksheet "Sheet1" of Workbook "xlTest1"
--> 4
set ScreenUpdating to true
end tell
--------------------------------
When screen updating is reinstated, workbook "xlTest1" is frontmost.
The script also works when the ScreenUpdating/true command is commented out:
--------------------------------
tell Application "Microsoft Excel"
set ScreenUpdating to false
Open "Hard Disk:Desktop Folder:Excel Tests:xlTest1"
--> Workbook "xlTest1"
Open "Hard Disk:Desktop Folder:Excel Tests:xlTest2"
--> Workbook "xlTest2"
Open "Hard Disk:Desktop Folder:Excel Tests:xlTest3"
--> Workbook "xlTest3"
Activate Window "xlTest1"
--> true
LastCell Range "A1" Direction xlToRight
--> Range "R1C4" of Worksheet "Sheet1" of Workbook "xlTest1"
get Column of Range "R1C4" of Worksheet "Sheet1" of Workbook "xlTest1"
--> 4
end tell
--------------------------------
(Even copy and paste commands work here with screen updating off.)
The above behaviour is what I would expect - or at least hope for.
To script Excel, I generally start without considering screen updating - so
I can see what's going on. In the final stages, I then insert screen
updating off/on commands at appropriate points. If turning off screen
updating cripples certain commands, I imagine quite a few of my Excel
scripts would fall over.
The behaviour of Excel X seems, in this respect, to be inconsistent with
previous versions. Since I don't consider the change an enhancement, I'm
still tempted to conclude that it's a bug.
---
kai
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.