How to get this script to repeat in MSWord?

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)

Hi there,

Is this any good?

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

Thanks for the reply! Sadly, that script does not work in MSWord for Mac 2008.

The hangup is MSWord’s use of a special return in footnotes. An error is returned during the replace function.

The following article describes a solution for PCs, but I was unable to craft an effective applescript.

I’d tried the script in Word 2011 :expressionless:

I’ve had a quick look at the article you’d listed, have you tried creating a macro in Word with what looks like the VBA code provided?

Word 2008 for Mac doesn’t support macros. Groan. I hesitate to upgrade to 2011 version due to negative reviews.

Not sure I could get all the VBA to work in applescript – just don’t have the experience. Will give it a try tho; thanks for recommendation.