The code I posted works as you requested. In order for it to work you must have a text string selected of between 3 and 7 characters, or it doesn't do anything. What did you have selected when you ran it?

The codes provided by my fellow contributors also work, though Paul has used a '*' character for the variable s1 rather than the 'X' you requested. However both those versions have the string hard coded, instead of using a selection. There is more than one way to achieve the requested result. You have had three variations offered. In what way don't they work for you?