Results 1 to 2 of 2
  1. #1
    Dave_D's Avatar
    Dave_D is offline Advanced Beginner
    Windows XP Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    67

    FileDateTime Function

    I'm trying to use the FileDateTime Function to determine if a file with my folder is older than 60 days to delete that file. My variable retval=Dir("C:\Users\*.xls") recognizes the first file named. My next statement, LastMod = FileDateTime(retval) issues a runtime error of 53. Suggestions!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    modified date is a property of the file accessed by:

    usage:

    vDate = getFileDate("c:\folder\file.txt")


    Code:
    Public Function getFileDate(ByVal pvFile)
    getFileDate = getFileProperty2(pvFile, 5)
    End Function
    
    
    Public Function getFileProperty2(ByVal pvFile, ByVal pvProp)
    'Dim XL As Excel.Application
    'PROPERTIES VALUES
    ' 9 Author
    '10 Title Author
    '11 Subject Title
    Dim vDir, f As String
    Dim vDat
    Dim sFolder As String
    Dim oShell, oFold, objFolder, oItm
    Dim fso
    
    
    getDirName pvFile, vDir, f
    sFolder = vDir
    
    
    Set oShell = CreateObject("Shell.Application")
    Set fso = CreateObject("scripting.FileSystemObject")
    Set oFold = fso.GetFolder(sFolder)
    Set objFolder = oShell.Namespace(oFold.Path)
    Set oItm = objFolder.Parsename(f)
    
    vDat = objFolder.GetDetailsOf(oItm, pvProp)
    
    getFileProperty2= vDat
    
    Set oShell = Nothing
    Set fso = Nothing
    Set oFold = Nothing
    Set objFolder = Nothing
    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 03-04-2016, 10:36 AM
  2. Replies: 8
    Last Post: 11-04-2014, 10:44 PM
  3. Replies: 8
    Last Post: 01-31-2014, 01:45 PM
  4. Can't run a function?
    By Kemo in forum Programming
    Replies: 4
    Last Post: 05-20-2012, 09:25 AM
  5. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums