Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 556665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:56:37+00:00 2026-05-13T11:56:37+00:00

I have some code which I found online and it’s working great. It lists

  • 0

I have some code which I found online and it’s working great. It lists any files in a specified folder and their properties. I just need to amend this function which returns a list of files. I need it to look in a given path at ALL files. So if it’s a folder, open it and return those files too. I eventually need to get this to mark each file (so in a column in excel) where it came from. If it would be possible to create a hirarchy somehow that would be great…. but for now, just opening a folder if it finds on and listing those files would be awesome!

Any help is REALLY appreciated!

Private Function fcnGetFileList(ByVal strPath As String, Optional strFilter As String) As Variant
'   Returns a one dimensional array with filenames
'   Otherwise returns False

Dim f As String
Dim i As Integer
Dim x As Integer
Dim FileList() As String

    If strFilter = "" Then strFilter = "*.*" 'can provide an extension to check?

    'set the path
    Select Case Right$(strPath, 1)
     Case "\", "/"
         strPath = Left$(strPath, Len(strPath) - 1)
    End Select

    ReDim Preserve FileList(0)

    f = Dir$(strPath & "\" & strFilter)

    Do While Len(f) > 0
        ReDim Preserve FileList(i) As String
        FileList(i) = f
        i = i + 1
        f = Dir$()
    Loop

    If FileList(0) <> Empty Then
        fcnGetFileList = FileList
    Else
        fcnGetFileList = False
    End If

End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:56:38+00:00Added an answer on May 13, 2026 at 11:56 am

    Ideas:

    Add the microsoft scripting runtime And use the file system object (much better file/folder handling)

    Make this function recursive, add a vbdirectory parameter to the dir function, and use GetAtrr to get info about each file. If the file is a folder again, call this function again with this new folder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code which collects points (consed integers) from a loop which looks
I have some code which utilizes parameterized queries to prevent against injection, but I
I have some code which I am making available via RMI. If my program
I have some code which needs to ensure some data is in a mysql
I have some code which returns InnerXML for a XMLNode. The node can contain
I have some code which ignores a specific exception. try { foreach (FileInfo fi
I have some code which I did not originally create that uses _beginthreadex and
I have have some code which adds new cells to a table and fills
On a small embedded system project we have some code which we would like
I have some Ruby code which takes dates on the command line in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.