Get all text files in a specified path to a userform listbox using VBA.
The code below will read the directory for all text files and its filename will be loaded to listbox.
=====================
Dim fs, f, fc, f1
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder("C:\text_folder")
Set fc = f.Files
For Each f1 In fc
If InStr(1, f1.Name, ".txt") Then
'add all filenames to listbox
UserForm1.ListBox1.AddItem f1.Name
End If
Next
=====================
Happy coding!
Cheers..till next time.
================================
Free Android Apps:
Click on links below to find out more:
Multiplication Table for early learners
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
https://play.google.com/store/apps/details?id=com.myrosaryapp
Comments
Post a Comment