Hello. I want to do a simple find/replace on a user-defined Word style. I rather optimistically tried this after looking at an example in the Word 2004 Applescript Reference:
tell application "Microsoft Word"
set myFind to find object of selection
tell myFind
clear formatting
set style of format to style with properties ¬
{name local:"section"}
execute find find text "" replace with "\\section{^&}" replace replace all
end tell
end tell
Predictably enough this doesn’t work. Any ideas how to fix it?
I want to find any text in my Word style called ‘section’ and put some mark-up on it.
This, however, does work:
tell application "Microsoft Word"
set myFind to find object of selection
tell myFind
clear formatting
set style of format to style heading1
execute find find text "" replace with "\\section{^&}" replace replace all
end tell
end tell
But it uses a default style called ‘Heading 1’, rather than my own called ‘section’.
Solved.
The answer, in case anyone is interested, is this:
tell application "Microsoft Word"
set myFind to find object of selection
tell myFind
clear formatting
set style of format to "section"
execute find find text "" replace with "\\section{^&}" replace replace all
end tell
end tell