Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Kill a file that is viewed through a listbox
Kill is the VBA command to delete a file. I don't think you want this.
I think you want: Close FileNum But if you really wanted to delete a file, you'll want to specify the location: kill "c:\TPALS Notemaker notes\" & me.listbox1.value But please make sure you do this against test data--or back up your data first! bluewatermist wrote: 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 -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Kill a file that is viewed through a listbox
Hi Dave
Thanks so much it worked :) I had been looking at such complicated ways and it was so simple. Much appreciated Frederic "Dave Peterson" wrote: Kill is the VBA command to delete a file. I don't think you want this. I think you want: Close FileNum But if you really wanted to delete a file, you'll want to specify the location: kill "c:\TPALS Notemaker notes\" & me.listbox1.value But please make sure you do this against test data--or back up your data first! bluewatermist wrote: 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can Two Sheets Be viewed at Sametime in One EXCEL File? | Excel Discussion (Misc queries) | |||
Font colours missing in excel file viewed from laptop. | Excel Discussion (Misc queries) | |||
Hyperlinks won't work when file is viewed in email | Excel Discussion (Misc queries) | |||
excel file cannot be viewed | Excel Discussion (Misc queries) | |||
File kill help | Excel Programming |