Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Search Files and Report Results in Date Range

I have found the code below that performs a search and outputs the results to
column A of a spreadsheet.

I need to modify this code to make 3 changes:
1) prompt the user for the directory of choice
2) prompt the user for a date range of .lastmodified and use that as an
additional search criteria
2) result to list all the files with the directory chosen in column A of the
Excel Workbook

The issue with the current code is that if I choose a path that has
subfolders it comes up "type mismatch" and won't give me the subfolders
information.

My goal is a full directory of all the contents of a path within a certain
date range where edits were made.

Thank you in advance.
-------------------------------
Function CreateFileList(FileFilter As String, _
IncludeSubFolder As Boolean) As Variant
' returns the full filename for files matching
' the filter criteria in the current folder

Dim FileList() As String, FileCount As Long
CreateFileList = ""
Erase FileList
If FileFilter = "" Then FileFilter = "*.*" ' all files
With Application.FileSearch
.NewSearch
.LookIn = "C:\Test\Templates"
.Filename = FileFilter
.SearchSubFolders = IncludeSubFolder
.FileType = msoFileTypeAllFiles
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) = 0 Then Exit Function
ReDim FileList(.FoundFiles.Count)
For FileCount = 1 To .FoundFiles.Count
FileList(FileCount) = .FoundFiles(FileCount)
Next FileCount
.FileType = msoFileTypeExcelWorkbooks ' reset filetypes
End With
CreateFileList = FileList
Erase FileList
End Function

Sub TestCreateFileList()
Dim FileNamesList As Variant, i As Integer
' ChDir "C:\My Documents"
' activate the desired startfolder for the filesearch
FileNamesList = CreateFileList("*.*", False)
' performs the filesearch, includes any subfolders
' present the result
Range("A:A").ClearContents
For i = 1 To UBound(FileNamesList)
Cells(i + 1, 1).Formula = FileNamesList(i)
Next i
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search for date within a range of dates [email protected] Excel Programming 1 October 10th 07 12:17 AM
Search All Files Find Newest One Report To Excel 2007 Stever Excel Programming 1 September 6th 07 02:24 AM
Generating a Weekly Report based on a Date Range, where 1 Column = 1 Day Arnold[_3_] Excel Programming 1 February 11th 07 11:40 PM
Sort community search results by date Martin Excel Programming 1 April 7th 06 02:29 PM
Search Range for Criteria in given cell and produce results RFreeman12 Excel Discussion (Misc queries) 3 June 27th 05 09:23 PM


All times are GMT +1. The time now is 12:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"