It sounds like the macro is causing the foreground app to lose focus, essentially putting it in the background even though it looks like it's still the frontmost app. Adding an "Activate a Specific Application" or "Bring Window to Front" action, perhaps followed by a "Pause Until [MENU ITEM IN TEXT EDITOR] is Enabled", right before running the macro that's supposed to copy the selected text seems like it should fix the problem. If it doesn't though, it would help if, in your follow-up post, you uploaded and included screenshots of all the macros involved in your desired process (preferably all uploaded locally to this forum, rather than to Dropbox or Droplr) along with telling us exactly what text editor you're using.
A few other miscellaneous comments on this sub-macro:
• If you're using KM8, you no longer need to set variables to
%Delete% to hide them. You can just prefix them with "Local" or "Instance" (depending on whether and how they're meant to be used as sub-macros) and they will be restricted to just that macro or that macro execution instance, thus achieving the same effect as setting them to
• Whether you set variables to
%Delete% or prefix them with "Local" or "Instance," if you're going to do that, there isn't any benefit to using them as placeholders in actions like this:
since they'll always be empty when the macro is run. If you want to use variables as placeholder values like this, you need to neither delete them nor prefix them with "Local" or "Instance" (in your current macro, just deleting or disabling the relevant "Set Variable to
%Delete%" actions would be the easiest way to do this and preserve the variables' values across macro executions). If you're setting these macro values in a different macro before this one is run, so that they will have placeholder values once the sequence reaches this point, then of course they'll serve their intended benefit, but in that case, you may want to consider setting and deleting these variables in the same macro, rather than setting them in one and deleting them in another (for future organizational ease-of-use if nothing else).
• If you're generating a new file every time the macro is run with this action:
Then you probably want to make this "Write Text" instead of "Append Text." If you do mean to append text to an existing file, then you probably don't want to use a variable for the file name, since that leaves room for consistency errors.
• This may have been intentional since the macro currently isn't working as you expect, but in the version you posted, the final "Execute a Macro" option is set to execute no macro. Perhaps that's also contributing to the unexpected behavior you're seeing?
Good luck with resolving this issue! As always, feel free to post again if you have further questions, and let us know how it goes!