2 Replies Latest reply on Nov 7, 2016 7:47 AM by N. S.

    Get filename of currently running macro file (VBA)

    N. S.

      Hello all. In VBA, is it possible to get the actual filename of the currently running macro? For instance, if I run a macro file named "macro.swp",  I want "macro.swp" returned as a string.

       

      To provide a little context, I've developed a macro that  displays a list of other macros that can be run from a shared drive. All available macros are placed into a shared folder on the shared drive, along with a text file. The text file contains information regarding which macros are to be included in the list as well as various options for each macro. My macro parses the text file to determine which macros to display in the list and how to run a particular macro when a user clicks on it.

       

      Currently, the filename of the text file is hardcoded into the macro. However, I would also like users to be able to make their own copy of this macro and create their own text file so that, if desired, in addition to the shared location, they can create their own personalized lists of macros. I do not want them to have to edit the macro code to make it point to a different text file. Hence why I would like this to be automatically handled within the macro itself so that I can just tell them, "If you want to make your own personalized list, rename your macro file to whatever you'd like, then give the text file the same name."

       

      Sorry if that's a lot of unnecessary detail, and thanks for any help!