Here are two test Macros to export a Macro's XML and then import it into Keyboard Maestro as a new Macro.
The first demo works (using Keyboard Maestro's menu option "Copy as... XML")
The second macro fails. It uses AppleScript to get the XML and fails on the import part.
I am assuming the problem is with the AppleScript I have for exporting the XML but I think the syntax is correct and it does indeed save the XML to the Variable. For some reason the XML exported via AppleScript is not liked for importing the Macro.
I've searched the Forum and Google Searches and Claude AI but not solved this so, I'm here asking for help!
I had never got this to work either. But, spurred on by it being someone else's problem rather than something I'd just work round...
I think the copied macro XML is missing important information needed for an import -- specifically, the Macro Group to import into. You attempt, and my previous, has the XML as eg:
Yes, that did it. I have added some AppleScript to automatically get the Group name and moved your code into the first part so that it assembles an XML ready to be imported. I left my original Import AppleScript unchanged as the generated XML is now good to be imported.
The goal in all this was to have a method that exports the XML text in a method that doesn't need replicating menu commands and doesn't use the System Clipboard and this now does this.
@Nige_S you are a genius. (@DanThomas you are a genius too, of course!)
Here is my final Macro (the AppleScript is in three Actions so that I know what is going on). The Magenta section does the Export - without needing to use the Clipboard. And the Purple section does the Import.