In Microsoft Word - need to find text and apply user defined style

I’m new to Applescript. I’m trying to do a simple Applescript for Microsoft Word:
I want to find a certain word, we’ll call it “TitleText”
Then I want to format the paragraph to a user defined paragraph style, call it “MyTitleStyle”

I’ve tried this:


tell application "Microsoft Word"
	set findRange to find object of selection
	tell findRange
		execute find find text "TitleText"
		set paragraph format of selection to Word style "MyTitleStyle"
	end tell
end tell

But, predictably, it doesn’t work.

How do I do this simple Applescript?

Thanks so much for your help!

I continue working on this.

I’ve tried this script


--working script

tell application "Microsoft Word"
	set findRange to find object of selection
	repeat 100 times
		tell findRange
			execute find find text "TitleText"
		end tell
		tell paragraph format of selection to set style to "MyTitleStyle"
	end repeat
end tell

This worked partially. It formatted the found text “TitleText” to the style “MyTitleStyle” but didn’t change the entire paragraph’s style, which is what I need it to do. “TitleText” is only the first word in the paragraph, I need the whole paragraph reformatted.

Note: I repeated 100 times simply because I’m not advanced enough to know how to stop an endless loop any other way!

Any help is appreciated.