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: Deivy Marck Petrescu <email@hidden>
- Date: Sun, 7 Mar 2010 13:14:34 -0500
On Mar 7, 2010, at 5:16 AM, Dr Digby L. James wrote:
> 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
Digby,
I do not use or script Word. however, I checked your script.
It runs here without a hitch even if you do not select anything in word.
It does not do anything but it does not crash or error
I checked Word's dictionary and found it with some problems.
I did not find any reference to a document nor to the text of a document.
I did find selection-object, which does not compile. Never found selection.
I understood you as talking about Word 2004.
Deivy Petrescu
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