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