View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
bluewatermist bluewatermist is offline
external usenet poster
 
Posts: 26
Default Kill a file that is viewed through a listbox

Hello

I'm have difficulty killing a file. Currently on the main userform there is
a command button that once clicked, opens another smaller userform which has
a listbox in it. The listbox displays all text files in a certain C drive
folder. Upon selecting the required file, this smaller userform gets hidden
and unloaded and goes back to the main userform pasting all the information
that was in the selected text file into relevant fields. I have tried using
Kill FileNum or Kill listbox1.value, but without any success. Below is the
coding so far I have used. Hoping you can help me.

Private Sub UserForm_Activate()

Me.ListBox1.Clear

Dim Filename As String
Dim Foldername As String

Foldername = "c:\TPALS Notemaker notes\"
Filename = Dir(Foldername)
Do Until Filename = ""
Me.ListBox1.AddItem (Filename)
Filename = Dir
Loop

End Sub

Private Sub selectcase_Click()

On Error Resume Next
Dim FileNum As Integer
Close
FileNum = FreeFile

Open ListBox1.Value For Input As #FileNum
Input #FileNum, a, b, c etc.......

CWC_Note.typeofcontact.Text = a: typeofentity.OptionButton1.Value = b:
typeofentity.OptionButton2.Value = c: etc.....

Kill FileNum

Close

SelectFile.Hide
Unload SelectFile

End sub