Re: Word crashing sometimes on find and replace
Re: Word crashing sometimes on find and replace
- Subject: Re: Word crashing sometimes on find and replace
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 07 Mar 2010 10:39:46 -0800
- Thread-topic: Word crashing sometimes on find and replace
1) You need to "clean out" the current Find and Replace settings (otherwise
the same settings currently used for Find and Replace in the UI will be
used). Such as:
tell findRange
set match all word forms to false
set match case to false
set match sounds like to false
set match whole word to false
set match wildcards to false
set no proofing to true
set format to false
execute find it find text myfind replace with myreplace replace
replace all
end tell
2) You are asking the script to *find* Bembo Std font, not specifically to
replace numbers in other fonts with Bembo Std. Is that what you mean to do?
3) Word 2004 is pretty old now. If I remember correctly, it was designed for
OS 10.3 and 10.2.8. It may have been updated once for 10.4 (I can't recall)
but has not had any upgrades to work with new issues introduced by OS 10.5,
let alone 10.6. It had some AppleScript problems that were fixed in Word
2008. Office 2008, being the latest version, has had some updates to make it
work smoothly with OS 10.5 and, I believe 10.6 (I'm not on 10.6 yet.)
I think that anything that works "sometimes" means there's no specific error
with the script, but that freezing and crashing issues could indicate some
version incompatibilities and/or instabilities. I'd recommend trying it out
in Word 2008.
--
Paul Berkowitz
> From: "Dr Digby L. James" <email@hidden>
> Date: Sun, 7 Mar 2010 10:16:59 +0000
> To: AppleScript-Users <email@hidden>
> Subject: Word crashing sometimes on find and replace
>
> I like using the old style numbers in documents, usually using Bembo Std as
> this is an OpenType font that has them. For Microsoft Word 2004 I had a script
> to do this but it was erratic, it would sometimes work and sometimes cause
> Word to freeze. I searched around and created a new one which seemed to work
> perfectly - till today, when Word has frozen again, requiring a force quit.
> Being no expert, I can't see what's wrong. The script is:
>
> _____________________
> myReplaceText("0", "")
> myReplaceText("1", "")
> myReplaceText("2", "")
> myReplaceText("3", "")
> myReplaceText("4", "")
> myReplaceText("5", "")
> myReplaceText("6", "")
> myReplaceText("7", "")
> myReplaceText("8", "")
> myReplaceText("9", "")
> display dialog "Script completed"
>
> on myReplaceText(myfind, myreplace)
> tell application "Microsoft Word"
> set findRange to find object of selection
> set name of font object of findRange to "Bembo Std"
> tell findRange
> execute find find text myfind replace with myreplace replace replace all
> end tell
> end tell
> end myReplaceText
> _____________________
>
> The log gives the following:
>
> tell application "Microsoft Word"
> get find object of selection
> --> find id 5.92697E+8 of selection
> set name of font object of find id 5.92697E+8 of selection to "Bembo Std"
> Result:
> error "Microsoft Word got an error: AppleEvent timed out." number -1712
>
> I just had a thought, as I was typing, was that when I ran this just now I had
> no text selected. When I restarted Word I selected all and ran it and it
> worked. If this is the problem (by why, as it has worked before), what changes
> do I need to make to the script to search the whole document?
>
> Dr Digby L. James
> Quinta Press
> Meadow View
> Weston Rhyn
> Oswestry
> Shropshire
> England
> SY10 7RN
> (44)(0)1691 778659
> http://www.quintapress.com
>
> _______________________________________________
> 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