Two short VBA programs to list folders and files and store results in an array

  • Posted:
  • Proposals: 5
  • Remote
  • #690004
  • Awarded
Pete R.
Valeriy S.Shahrukh M.VBIS I.Alok A. have already sent a proposal.
  • 0


Experience Level: Intermediate
General information for the business: Two rutines to list the files in a folder and the fles in any of its sub-folders
Kind of development: New program from scratch
Num. of modules: 2 progams
Description of every module: This should consist of two VBA programs running in Excel V10:

Findiles & getfoldercontents (this may be called recursively every time a folder is encountered)

Option explicit
Public sub findfiles(byval strpath as string)
Dim stritems(1000)as string, intlevel as integer, intcount as integer
getfoldercontents strpath, stritems(), intlevel, intcount
End sub

findfolders just calls getfoldercontents and provides the arrays in which the results of calling getfoldercontents are to be saved.

Strpath is the opening path (e.g: c:\test).

On each call to getfoldercontents, it should increase the value of intcount by 1 and add the name of the folder now being searched to stritems(intcount) which should be set:


Then intlevel is increment by 1 and all the files in the folder are added to stritems and intcount incremented by 1 for each file name added:

stritems(intcount) = string(intlevel,chr(9))+

Just prior to each exit from getfoldercontents, intlevel is reduced by 1.
Description of requirements/functionality: Outputs a string array listing all the folders and files in the initial root folder. The intlevel parameter sets thr enumber of chr(9) tabs
OS requirements: Windows
Extra notes:

New Proposal

Create an account now and send a proposal now to get this job.

Sign up

Clarification Board Ask a Question

    There are no clarification messages.