Helper monkey
Board Regular
- Joined
- Jun 23, 2002
- Messages
- 63
Hi Mudface,
Thanks for your modified function. I've placed it in my user form but couldn't find the check box in references that you refered to -?). I'm running excel 97 if that helps explain the problem.
When running the code the debugger says that the 'user-defined type is not defined' on the First line of the code (Dim myFileSystem...)
Private Sub UserForm_Initialize()
Dim myFileSystem As New Scripting.FileSystemObject
Dim myFolder As Scripting.Folder
Dim myFiles As Scripting.Files
Dim myFile As Scripting.File
Const TargetFolder As String = "C:\My Documents\"
Const myExtension As String = "*.xls"
On Error Resume Next
Set myFolder = myFileSystem.GetFolder(TargetFolder)
If Err <> 0 Then MsgBox "Unable to find folder.": Exit Sub
Set myFiles = myFolder.Files
For Each myFile In myFiles
If Right(LCase(myFile.Name), 4) Like myExtension Then
Me.ListBox1.AddItem myFileSystem.GetBaseName(myFile.Name)
End If
Next myFile
Set myFolder = Nothing
Set myFileSystem = Nothing
End Sub
Thanks in advance for your help.
Just noted that your from Hull, are you lucky enough to get 'Look North'? Or do you manage to escape it's reaches - Stunning interview techniques etc... :wink:
Thanks for your modified function. I've placed it in my user form but couldn't find the check box in references that you refered to -?). I'm running excel 97 if that helps explain the problem.
When running the code the debugger says that the 'user-defined type is not defined' on the First line of the code (Dim myFileSystem...)
Private Sub UserForm_Initialize()
Dim myFileSystem As New Scripting.FileSystemObject
Dim myFolder As Scripting.Folder
Dim myFiles As Scripting.Files
Dim myFile As Scripting.File
Const TargetFolder As String = "C:\My Documents\"
Const myExtension As String = "*.xls"
On Error Resume Next
Set myFolder = myFileSystem.GetFolder(TargetFolder)
If Err <> 0 Then MsgBox "Unable to find folder.": Exit Sub
Set myFiles = myFolder.Files
For Each myFile In myFiles
If Right(LCase(myFile.Name), 4) Like myExtension Then
Me.ListBox1.AddItem myFileSystem.GetBaseName(myFile.Name)
End If
Next myFile
Set myFolder = Nothing
Set myFileSystem = Nothing
End Sub
Thanks in advance for your help.
Just noted that your from Hull, are you lucky enough to get 'Look North'? Or do you manage to escape it's reaches - Stunning interview techniques etc... :wink: