Change Recorded Macro to work on different files?

I created this macro recording using the standard filter to leave only rows that do not end with the letter “A” in a serial number column. However, when I try to use it on a different file (or workbook, I’m not sure if that means the same thing), it does not work.
How can you make a macro work independently from the file in which it was created?

REM ***** BASIC *****

sub Main
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService(“com.sun.star.frame.DispatchHelper”)

rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, “.uno:DataFilterStandardFilter”, “”, 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, “.uno:FilterExecute”, “”, 0, Array())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, “.uno:DataAreaRefresh”, “”, 0, Array())

end sub

It is a question of where it is stored, Kirk.

You are asked at macro save where you want it to be stored. If you choose the document, then it will be available only to that file. If within your profile, then available to all docs that you run. And so on.