I have a script for MSWord 2008 but can’t get it to repeat. Trying to replace double-returns (^p^p) in footnotes w/ single return. Extra returns are added when copying content from InDesign CS4.
Script below works one time; when I uncomment the “repeat” lines the script doesn’t complete the first set of commands.
tell application "Microsoft Word"
-- repeat
set findRange to find object of selection
tell findRange
execute find find text "^p^p"
tell application "System Events"
key code 53
key code 124
key code 123
key code 51
end tell
-- if (not (execute find find text "^p^p")) then
-- exit repeat
-- end if
end tell
-- end repeat
end tell
BTW, keycodes mimic the process when this routine is done manually through find/replace.
Thanks in advance for your thoughts!
Model: macmini
AppleScript: 2.1.2
Browser: Safari 534.59.10
Operating System: Mac OS X (10.6)
tell application "Microsoft Word"
set myRange to text object of active document
execute find find object of myRange find text "^p^p" replace with "^p" replace replace all
end tell