using Whose statement in MS Word

Hi,

I’ve found a way to do what I want in MS Word, but using repeat loops. I’d like to convert them to whose statement to speed things up.

Here’s the script using repeat loops


tell application "Microsoft Word"
	set myDocument to active document
	set myTables to tables of myDocument
	repeat with i from 1 to (count of myTables)
		set myTable to item i of myTables
		
		select myTable
		try
			repeat with i from 1 to (count of rows of selection)
				set myRow to row i of selection
				if color index of (get border myRow which border border bottom) is red then
					set line style of (get border myRow which border border bottom) to None
				end if
				if color index of (get border myRow which border border top) is red then
					set line style of (get border myRow which border border top) to None
				end if
			end repeat
		end try
		
		--Fix for First and second cell
		set myFirstCell to cell 1 of selection
		
		if color index of (get border myFirstCell which border border bottom) is red then
			set line style of (get border myFirstCell which border border bottom) to None
		end if
		set mySecondCell to cell 2 of selection
		if color index of (get border mySecondCell which border border bottom) is red then
			set line style of (get border mySecondCell which border border bottom) to None
		end if
		
		try
			repeat with i from 1 to (count of columns of selection)
				
				set myColumn to column i of selection
				if color index of (get border myColumn which border border left) is red then
					set line style of (get border myColumn which border border left) to None
				end if
				
				if color index of (get border myColumn which border border right) is red then
					set line style of (get border myColumn which border border right) to None
				end if
			end repeat
		on error
			repeat with j from (count of cells of selection) to 1 by -1
				set myCell to cell j of selection
				if color index of (get border myCell which border border left) is red then
					set line style of (get border myCell which border border left) to None
				end if
				
				if color index of (get border myCell which border border right) is red then
					set line style of (get border myCell which border border right) to None
				end if
			end repeat
			
		end try
	end repeat
	activate
	beep
end tell

I’ve tried a couple of things using whose statement but none of them work. the get border which border border bottom bit is pretty hard to transform.

	
set myCells to (tables)'s cells whose color index of (get border which border border bottom) is red

this gives me en error, I think I should have something right after the get border like in my working script, but I don’t know what to put there.

Anyway to achieve this in MS Word?
TIA
Jeff