VBA - Identify name of the file

  • Hi,
    I have following problem. Im sharing some file wich contain macro to automaticly send e-mail from Lotus Notes and I want to make my coworkers to use it. Underlined value in the script is name of the nsf file wich is contained in the same directory in their computers (its the only file in this folder). I want to change macro to somehow identify name of the file and insert it in outlined command in the scirpt so whenever some1 opens it from other computer macro will still work. Or if its too hard to achieve i want to use the "if" command to the code and add 2 coworkers file name but im not good enough with VBA.


    directory of the file:

    Code
    C:\Users\xxxx\AppData\Local\IBM\Notes\Data\mail\gdansk




    /code

    \code

  • Re: VBA - Identify name of the file


    You can get the AppData directory using the Environ function and the NSF file using Dir. Example function:



    Note the parameter is passed ByRef so strFileName will be populated with the name of the NSF file if it exists. Check the return value of the function before setting OutDoc.

  • Re: VBA - Identify name of the file


    It's a standard VBA function that returns a string and is not difficult to integrate it into your code.


    Copy the function to a code module. Declare a variable in your procedure. Call the function passing that variable and replace the xxx.nsf in your original code with the variable if the function returns True.


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!