Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Two Sheets Be viewed at Sametime in One EXCEL File? Gatedweller Excel Discussion (Misc queries) 1 May 7th 09 11:50 AM
Font colours missing in excel file viewed from laptop. Techy46 Excel Discussion (Misc queries) 4 May 14th 08 04:28 PM
Hyperlinks won't work when file is viewed in email Alex Excel Discussion (Misc queries) 2 August 29th 07 08:54 PM
excel file cannot be viewed FooYC Excel Discussion (Misc queries) 2 June 16th 05 11:02 PM
File kill help Marino13[_6_] Excel Programming 0 February 19th 04 01:40 PM


All times are GMT +1. The time now is 02:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"