How do I enable users to drag files from a folder or the desktop, drop to a ListBox and have it so it creates a copy of the file in the folder that the list box is reading from?
Private Sub Form_Load()
ListDir "c:\", "*.*"
End Sub
Private Sub ListDir(ThisPath As String, ThisPattern As String)
On Error GoTo 1
Dim Thisfile As String
Dim char As String
List1.Clear
If Right$(ThisPath, 1) <> "\" Then ThisPath = ThisPath + "\"
Thisfile = Dir$(ThisPath + ThisPattern, 0)
List1.Tag = ThisPath
Dim x As Integer
ReDim arrFile(0)
Do While Thisfile <> ""
ReDim Preserve arrFile(x)
arrFile(x) = Thisfile
x = x + 1
On Error Resume Next
char = InStrRev(Right(Thisfile, 5), "."
On Error GoTo 0
Select Case char
Case 1, 2, 3, 4
List1.AddItem Left(Thisfile, Len(Thisfile) - (5 - char + 1))
Case Else
'Unknown extension so add the file to list
List1.AddItem Thisfile
End Select
Thisfile = Dir$
Loop
Exit Sub
1 MsgBox "Drive not reading"
End Sub
Private Sub Form_Load()
ListDir "c:\", "*.*"
End Sub
Private Sub ListDir(ThisPath As String, ThisPattern As String)
On Error GoTo 1
Dim Thisfile As String
Dim char As String
List1.Clear
If Right$(ThisPath, 1) <> "\" Then ThisPath = ThisPath + "\"
Thisfile = Dir$(ThisPath + ThisPattern, 0)
List1.Tag = ThisPath
Dim x As Integer
ReDim arrFile(0)
Do While Thisfile <> ""
ReDim Preserve arrFile(x)
arrFile(x) = Thisfile
x = x + 1
On Error Resume Next
char = InStrRev(Right(Thisfile, 5), "."
On Error GoTo 0
Select Case char
Case 1, 2, 3, 4
List1.AddItem Left(Thisfile, Len(Thisfile) - (5 - char + 1))
Case Else
'Unknown extension so add the file to list
List1.AddItem Thisfile
End Select
Thisfile = Dir$
Loop
Exit Sub
1 MsgBox "Drive not reading"
End Sub