The error is giving you a clue: "Symbol's value as variable is void"
my-macro is not a variable containing a value. You need to quote the macro like that: 'my-macro
(or the equivalent (quote my-macro)
)
If you really want to execute the macro in all buffers (beware the buffers like *Messages*
and so), this would be a programatic alternative
(defun execute-my-macro-in-all-buffers ()
(interactive)
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(if (and buffer-file-name
(y-or-n-p (format "Execute macro in %s? " buffer-file-name)))
(execute-kbd-macro 'my-macro)))))