Macro to rename tab in calc

Hi, I need to link an external sheet for its file name, NOT for the tab name (in the source file it changes). I know, it’s not possible, so, is there a macro I can save in calc that automatically rename the active tab in a sheet?