HEEEELP on file code?

  • I have this code below.......and I want it to return the filename on the last modified file in the folder I have defined. My messagebox in the end just returns "false".......and I had hoped it would return some kind of filename. Could anyone tell me how I can rewrite my code in order to make it show the filename?




    Thanks, Lars

  • Quote from Turbothorup

    I have this code below.......and I want it to return the filename on the last modified file in the folder I have defined. My messagebox in the end just returns "false".......and I had hoped it would return some kind of filename. Could anyone tell me how I can rewrite my code in order to make it show the filename?




    Thanks, Lars



    hi Lars,


    the biggest problem I can see there is that you have the variable assignment around the wrong way, where you have:

    Code
    .Filename = fname


    to do what I think you want to do, it should be:


    Code
    fname = .Filename


    the next problem is your function name 'Findes' is declared as a Boolean so the msgbox will only display TRUE or FALSE.


    so, if fname actually gets assigned to a filename, you may want to try:


    Code
    MsgBox fname


    or make the necessary adjustments to the function return type.


    Paul.

  • ok maybe forget that first point, i am not totally familiar with .FileSearch but i think you either want to set the fname variable before that statement or assign it to the .FileSearch.Filename property after the statement is executed.


    my comment about the msgbox is still valid. : D

  • Hi again....now the code looks like this.....



    Can anyone tell me why the messagebox is empty? Would like it to return a filepath or a filename.......something.... :thanx:

  • Lars, not sure if this will help, had a 2minute fiddle to see what was going on,



    sorry it probably doesn't do what you want at this stage but maybe it will help you see a little of what is happening?

  • helped a lot......still do not know why it returns a messagebox with the names of all the files in the folder - thought I had done so it would only find the last modified......anyway, thank you very much......great help

Participate now!

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