yinkajewole
Active Member
- Joined
- Nov 23, 2018
- Messages
- 281
I have a userform code that open file lists.
I need the following help in perfecting it.
1) the code for the search box to automatically search as soon as i type
2) the path called 'PathLabel', the code to get folder path
3) the code that changes the file list each time I change the folder path
Also asked here
https://www.excelforum.com/excel-pr...rform-for-getting-folder-path-and-others.html
I need the following help in perfecting it.
1) the code for the search box to automatically search as soon as i type
2) the path called 'PathLabel', the code to get folder path
3) the code that changes the file list each time I change the folder path
Code:
Function FileArray(Path As String)
Dim Name As String, Counter As Integer, Files() As String
Name = Dir("C:\Users\USER\Documents\*.xls", vbNormal)
Counter = 0
Do While Name > ""
If Name > "." And Name > ".." Then
ReDim Preserve Files(Counter)
Files(Counter) = Name
Counter = Counter + 1
End If
Name = Dir
Loop
FileArray = Files()
End Function
Private Sub PathLabel_Click()
Dim wbStore, wbSource As Workbook, wsStore, wsSource As Worksheet, LastRow As Long
Dim FilePath As String, FileName, FullName As String
Dim blnOpened As Boolean
Dim iCount As Integer
Dim fso As FileSystemObject
Set fso = CreateObject("scripting.filesystemobject")
Set file1 = fso.GetFolder("textboxt1.text")
End Sub
Private Sub UserForm_Initialize()
Dim Files As Variant, NewDocument As Variant, Folder As String
Folder = "C:\Users\USER\Documents\" ' ENTER PATH HERE
Files = FileArray(Folder)
For Each NewDocument In Files
FileList.AddItem NewDocument 'ASSUMING U HAVE A LISTBOX FileList IN THE FORM
Next
End Sub
Private Sub OK_Click()
Dim Folder As String
Folder = "C:\Users\USER\Documents\" ' ENTER PATH HERE
Workbooks.Open (Folder + FileList.Value)
End Sub
Also asked here
https://www.excelforum.com/excel-pr...rform-for-getting-folder-path-and-others.html
Last edited by a moderator: