I’m not well-versed in recording macros, I’m afraid, but I would strongly recommend looking at the more robust method of hiding notes using a noteheadless notehead set.
The trick (as I mentioned in the post I linked, which comes from other users’ advice) is to add text to the notehead that consists of several Spaces - to ensure you can still select the notehead once you’ve changed it - and to make sure you’re not editing a notehead used in other sets. Creating a brand new notehead set and adding a new notehead (and removing the default black notehead) should be sufficient.
Or, if you’re hiding chords that you want to hear in playback but don’t want to appear in the music anywhere, why not write them on a staff that you hide using manual staff visibility?
As for ledger lines and accidentals - these are separate from the notehead, and have respective properties (links here for ledger lines and here for accidentals).