applicationfilesearch
Microsoft Office TrainingThe UK's Number 1 for Microsoft Office Training Sitemap add this page to your favourites/bookmarksBookmark page
 
view a printable version of this pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Application.Filesearch

Application.Filesearch

resolvedResolved · Urgent Priority · Version 2007

replyReplyMon 25 Jan 2010, 15:46Delegate Jonathan said...

Application.Filesearch

Hi there,
I had written a macro in Excel 2003 which searches a directory and lists all of the files in that directory, of type *.ssn and writes this list to a worksheet. To do this i used the Application.Filesearch functionality. Having upgraded to Excel 2007 this no longer works and it would appear the Filesearch functionality has been removed. The code i used is below - could you suggest how i can get this working in Excel 2007 please. Note I no longer need it to be able to work in Excel 2003.
Regards,
Jonathan

Sub ListAllFiles()


Dim fs As FileSearch
Dim ws As Worksheet
Dim i As Long


Set fs = Application.FileSearch


'Clear the current File List
Sheets("MISC").Range("AL49:AL128").ClearContents


'Create a new File List - all *.ssn files in the strDataLocation data directory
With fs

.SearchSubFolders = False ' set to true if you want sub-folders included
'.FileType = msoFileTypeAllFiles 'can modify to just Excel files eg with msoFileTypeExcelWorkbooks
.Filename = "*.ssn" 'Can use wildcards for file types.
.LookIn = strDataLocation 'modify this to where you want to serach

If .Execute > 0 Then

Set ws = Worksheets("MISC")

For i = 1 To .FoundFiles.Count

ws.Cells(i + 48, 38) = Mid$(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)

Next

Else

MsgBox "No files found"

End If

End With


End Sub

For upcoming training course dates see: Pricing & availability

replyReplyWed 27 Jan 2010, 14:03 Edited on Wed 27 Jan 2010, 14:04Trainer Stephen said...

RE: Application.Filesearch

Hi Jonathon

Thanks for your question

The removal of the filesearch method in 2007 is annoying, and puzzling.

It is possible to use the Dir method, which is very old dating back to pre windows versions of basic. It is hard to give a precise example of how to use this as I would need to know more about your file structures etc. But I suggest some sort of loop , using the Dir method, that looks at each file in turn and then writes it to the sheet if its extension matches your category.

I have found the following link that outlines some uses of the dir method, which you might find useful.

http://www.ozgrid.com/forum/showpost.php?p=369573&postcount=4

If you have any further queries please do not hesitate to get back to me.

Regards

Stephen

Tue 2 Feb 2010: Automatically marked as resolved.

 

 

Please browse our web site to find out more about
excel classes and other Microsoft training courses.

Excel tip:

Hiding Formulae in the Formula Bar

It is possible to protect the contents of a cell reference(s) from amendment by applying cell protection. The contents of the cell reference can also be stopped from displaying in the formula bar.

Step 1: Select Format > Cells > Protection.

Step 2: Tick Hidden option. Ensure Locked is ticked

Step 3: Select Tools > Protection > Protect Sheet

(Ensure "Protect worksheet and contents of locked cells" is ticked)


View all Excel hints and tips

forum postHow can I use formulas on a new sheet relating to previous sheets ie. adding numbers cell from previous sheets?

» Forum post: Formulas

article

How To Save And View Multiple Baselines In Microsoft Project

Baselines can be an invaluable tools within your Project plan, but Microsoft will normally only show your first baseline on the Gantt chart. Find out in this article how to display additional baselines and interim plans, and really enhance your Gantt charts

» Article: Ms project training course


Rate this page:
2.2/5 (213 votes cast)
Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses
Microsoft Certified Partner
Security Seal verified by visa, mastercard securecard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Management training

Professional Skills courses
Project Management Course London
Project Management Courses London
Project Management Training London
Project Management Training
Project Seminar
Project Seminars
Time Management Course London
Time Management London
Time Management Courses London
Time Management Training London
Introduction to Finance course
Assertiveness Skills course
Effective Communications Skills training
Presentation Skills London

Training Formats

Public scheduled courses
On-site training
Closed company courses

Consultancy
Application Development

Blogs

Excel Training
MS Project Training
Microsoft Training Blog

Version differences

Office 2010 vs 2007
MS Project version differences

Training Information

London Computer Training
Computer Training London
Docklands Training Courses
Docklands Training London

Training venues London
Client list
FAQ
Pricing and availability
Course details / Syllabus

Training Articles
Training Information

Microsoft training

Microsoft Office training
& IT Applications

Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training
MS Project courses
MS Project training
Outlook courses
PowerPoint courses
PowerPoint training
VBA courses
Word courses
Microsoft.training
(more...)

Excel Training

Excel courses
Excel Training Courses Medway
Autonumber in Excel
Microsoft Excel training
Basic Excel Courses
Basic Excel Course
Basic Excel Training

Interested in MS Access training?

Access courses
Microsoft Access training
Microsoft access courses
Microsoft training access course
Microsoft+access+training
Access courses in london

Training provider

Training providers
IT training companies
IT training providers
Management Training providers
Management Training provider

Event history, feedback results
Events in 2012 · 2011 · 2010 · More

See also

Crystal Reports training