Avoiding Word & Excel AppleEvent Crashes
Microsoft Word and Excel can crash frequently when the Script Debugger Explorer is used. These crashes can also be caused by AppleScript. Here are some tips for avoiding many of these crashing bugs.
1) Turn off Script Debugger’s ‘Scan for elements of count fails’ Dictionary preferences option
Doing this will make it much less likely that Script Debugger’s Explorer will generate AppleEvents that cause Word or Excel to crash.
2) Avoid using the Exists commands in your scripts
I have found that asking Word or Excel if a non-existent object exists will very often cause a crash. For example, if you open a new document and run the following script, Word will crash:
tell application "Microsoft Word"
exists shape 1 of selection
The workaround is to use count:
tell application "Micorosft Word"
return count shapes of selection >= 1