Re: Scripting MSWord
Re: Scripting MSWord
- Subject: Re: Scripting MSWord
- From: Thomas Maffucci <email@hidden>
- Date: Wed, 06 May 2009 14:38:30 -0400
- Thread-topic: Scripting MSWord
on Tue, 05 May 2009 20:25:22
Sutapalli Satyanarayana wrote
>I am trying to write apple script on MS Word document.
>In my MSWord 2008, I created my own styles to apply on >some paragraphs, lines
>etc.
>I want to search for a word in the document. If that word >is found, then the
>style of whole paragraph must be >changed to "Comment" (custom style created by
>me. This >style includes font, size, justification, border, keep >with next).
>I tried different combinations reading the >Word2004AppleScriptRef.pdf which I
>downloaded from web.
>Can some body tell me how can I do it -"Search for a word >and apply user style
>on whole paragraph"
This Should do the the Trick:
tell application "Microsoft Word"
set myDoc to active document
set myRange to create range myDoc start 0 end 0
--select text object of active document
select myRange
set srcfld to "Recent Transactions" -- change to your word
set EFind to find object
set EFind to find object of selection
clear formatting EFind
set content of EFind to srcfld
execute find EFind with match
select (next range (text object of selection) by a paragraph item count 1)
select (next range (text object of selection) by a paragraph item count -1)
set style of selection to style heading1 --change to Custom style Comment
end tell
_______________________________________________
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