Bring Application Window To Front Not Working

Have you tried the Assistance window’s “Something expected is not happening” option from the Help menu? Try that first and see if it clears anything up.

That said, rather than using a macro like this to automate finding and replacing in Pages, I think you might be better served by sticking with a macro like the one in your other recent topic that conducts search and replace entirely in the clipboard (or better, a variable) with more robust KM actions, then pasting the results back into Pages. Of course, if you have complex formatting in Pages, I can understand why that might not work for the entire document, but if it’s possible to only copy and search-and-replace select sections of the document, I can’t help but think that might still be a better option.