Hi,
I am unsuccessfully trying to use a function to return the date modified with the below Sub AKAname. Perhaps I should rename some variable names, but I'm not really sure if that is right, or how to streamline the Function LastModified with the Sub AKAname (listed below). Any help is much much appreciated!
Sub AKAname()
Range("A65536").End(xlUp).Select
Selection.Offset(1, 0).Select
Dim FSO As Object
Dim strName As String
Dim strArr(1 To 1048576, 1 To 1) As String, i As Long
CurrentRow = ActiveCell.Row
' Enter the folder name here
Const strDir As String = "Q:\AKAname\in\" ' drive you're searching
Let strName = Dir$(strDir & "**") 'insert file type if you'd like
Do While strName <> vbNullString
Let i = i + 1
Let strArr(i, 1) = strDir & strName
Let strName = Dir$()
Loop
Set FSO = CreateObject("Scripting.FileSystemObject")
'currently voided out: Call recurseSubFolders(fso.GetFolder(strDir), strArr(), i)
Set FSO = Nothing
'good place to stop...code that was here begins with: If i > 0 Then
If i > 0 Then
'Range("A1").Resize(i).Value = strArr
Range("A65536").End(xlUp).Select
Selection.Offset(1, 0).Select
End If
End Sub
Function LastModified(ByRef Folder As Object, _
ByRef strArr() As String, _
ByRef i As Long) '(Optional Filename As String) '(strArr As String) '(Filename As String)
Dim FSO As Object
Dim oFile As Object
'Dim Filename As String
If Len(Folder(strArr)) = 0 Then
'If Len(strArr)) = 0 Then
'If Len(Dir(strArr)) = 0 Then
'If Len(Dir(Filename)) = 0 Then
LastModified = CVErr(xlErrValue)
Else
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFile = FSO.getfile(strArr)
'Set oFile = FSO.getfile(Filename)
LastModified = oFile.DateLastModified
End If
Set oFile = Nothing
Set FSO = Nothing
End Function
I am unsuccessfully trying to use a function to return the date modified with the below Sub AKAname. Perhaps I should rename some variable names, but I'm not really sure if that is right, or how to streamline the Function LastModified with the Sub AKAname (listed below). Any help is much much appreciated!
Sub AKAname()
Range("A65536").End(xlUp).Select
Selection.Offset(1, 0).Select
Dim FSO As Object
Dim strName As String
Dim strArr(1 To 1048576, 1 To 1) As String, i As Long
CurrentRow = ActiveCell.Row
' Enter the folder name here
Const strDir As String = "Q:\AKAname\in\" ' drive you're searching
Let strName = Dir$(strDir & "**") 'insert file type if you'd like
Do While strName <> vbNullString
Let i = i + 1
Let strArr(i, 1) = strDir & strName
Let strName = Dir$()
Loop
Set FSO = CreateObject("Scripting.FileSystemObject")
'currently voided out: Call recurseSubFolders(fso.GetFolder(strDir), strArr(), i)
Set FSO = Nothing
'good place to stop...code that was here begins with: If i > 0 Then
If i > 0 Then
'Range("A1").Resize(i).Value = strArr
Range("A65536").End(xlUp).Select
Selection.Offset(1, 0).Select
End If
End Sub
Function LastModified(ByRef Folder As Object, _
ByRef strArr() As String, _
ByRef i As Long) '(Optional Filename As String) '(strArr As String) '(Filename As String)
Dim FSO As Object
Dim oFile As Object
'Dim Filename As String
If Len(Folder(strArr)) = 0 Then
'If Len(strArr)) = 0 Then
'If Len(Dir(strArr)) = 0 Then
'If Len(Dir(Filename)) = 0 Then
LastModified = CVErr(xlErrValue)
Else
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFile = FSO.getfile(strArr)
'Set oFile = FSO.getfile(Filename)
LastModified = oFile.DateLastModified
End If
Set oFile = Nothing
Set FSO = Nothing
End Function