Solved

Retreiving a list of files from a directory

Posted on 2002-06-24
2
164 Views
Last Modified: 2010-05-02
I want to browse a certain directory on a hard drive for a certain file type.
I can do this with the FileListBox (using the Pattern and Path properties) but I want to change the display so the file extension isn't shown.
What I could really do with is an API call that returns a list or windows handles to the files in the directory.

Any ideas?

Thanks,
Andy.
 
0
Comment
Question by:HelpAndy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 7103425
Use a listbox and the Dir() function:

Private Sub PopFiles(ByVal Pattern As String, ByVal SourcePath As String, ByRef LBox As ListBox)
  Dim strFileName As String
  LBox.Clear
  strFileName = Dir(SourcePath & "\" & Pattern)
  Do While strFileName <> ""
    LBox.AddItem Left(strFileName,Instr(strFilename,".") - 1)
    strFileName = Dir()
  Loop
End Sub

Then call like:

PopFiles "*.txt","c:\Myfolder",List1

To get a list box filled with the filenames minus the extension.
0
 

Author Comment

by:HelpAndy
ID: 7103450
You beauty, thanks Tim.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question