gibbo1715
02-18-2005, 02:24 PM
Can anyone tell me why im getting the error loop without do in the code below ?
Dim fso As Object, _
ShellApp As Object, _
File As Object, _
SubFolder As Object, _
Directory As String, _
Problem As Boolean, _
ExcelVer As Integer
On Error Resume Next
Me.ListBox1.Clear
Application.ScreenUpdating = False
Set fso = CreateObject("Scripting.FileSystemObject")
Do
Problem = False
Set ShellApp = CreateObject("Shell.Application"). _
Browseforfolder(0, "Please choose a folder", 0, "")
On Error Resume Next
Directory = ShellApp.self.Path
Set SubFolder = fso.GetFolder(Directory).Files
If Err.Number <> 0 Then
If MsgBox("You did not choose a valid directory!" & vbCrLf & _
"Would you like to try again?", vbYesNoCancel, _
"Directory Required") <> vbYes Then
Unload Me
Exit Sub
Problem = True
End If
On Error GoTo 0
Loop Until Problem = False <<<< error here
ListBox1.RowSource = ""
For Each File In SubFolder
If Right(File.name, 3) = "doc" Then _
Me.ListBox1.AddItem Left(File.name, Len(File.name) - 4)
Next File
FileDir = Directory
Application.ScreenUpdating = True
Dim fso As Object, _
ShellApp As Object, _
File As Object, _
SubFolder As Object, _
Directory As String, _
Problem As Boolean, _
ExcelVer As Integer
On Error Resume Next
Me.ListBox1.Clear
Application.ScreenUpdating = False
Set fso = CreateObject("Scripting.FileSystemObject")
Do
Problem = False
Set ShellApp = CreateObject("Shell.Application"). _
Browseforfolder(0, "Please choose a folder", 0, "")
On Error Resume Next
Directory = ShellApp.self.Path
Set SubFolder = fso.GetFolder(Directory).Files
If Err.Number <> 0 Then
If MsgBox("You did not choose a valid directory!" & vbCrLf & _
"Would you like to try again?", vbYesNoCancel, _
"Directory Required") <> vbYes Then
Unload Me
Exit Sub
Problem = True
End If
On Error GoTo 0
Loop Until Problem = False <<<< error here
ListBox1.RowSource = ""
For Each File In SubFolder
If Right(File.name, 3) = "doc" Then _
Me.ListBox1.AddItem Left(File.name, Len(File.name) - 4)
Next File
FileDir = Directory
Application.ScreenUpdating = True