Even if we use an Add Footer or Add Header filter as a subfilter of the search/replace, we can only use Macro at the start or end of file, not the middle of file. I want to insert Macro in the middle of a file.
When you add a subfilter of a search/replace, it operates on the replacement text as though it is a new file. So, by using a pattern, you can insert the text wherever you like.