PC Review


Reply
Thread Tools Rate Thread

Deleting a txt file after reaqing it

 
 
Jeff W.
Guest
Posts: n/a
 
      13th Oct 2007
My work book prompts me for a txt file that I read data onto one of
my sheets to, and I want to delete this txt file after the read.

I'm not sure how to do this, can anyone offer advice

Thanks,

Jeff W.


 
Reply With Quote
 
 
 
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      13th Oct 2007
You could use VBA's Kill statement to remove the text file; however, you
should understand that the removal is permanent... a copy of the Kill'ed
file will NOT be in your Recycle Bin afterwards. I mention this because if
you read the file in, then Kill it, and your system should crash before you
save the spreadsheet, the data will be lost and the original text file will
not be recoverable. You could consider using the FileCopy statement to copy
the file into a Temp directory, then Kill it from its original location;
that way, you could delete it with your regular Temp directory clean up
sometime later on when you have safely saved the spreadsheet and/or backed
up your system.

Rick


"Jeff W." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> My work book prompts me for a txt file that I read data onto one of
> my sheets to, and I want to delete this txt file after the read.
>
> I'm not sure how to do this, can anyone offer advice
>
> Thanks,
>
> Jeff W.
>


 
Reply With Quote
 
Jeff W.
Guest
Posts: n/a
 
      13th Oct 2007
Thanks for the reply Rick, however I do understand the risks of data loss
and the particular txt file is generated by another application, it isnt
sensitive
data or un replaceable data, so that wount be an issue.

Can you show me exmaple of how to use the kill command to delete a txt file?

Thanks,

Jeff W.




"Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> You could use VBA's Kill statement to remove the text file; however, you
> should understand that the removal is permanent... a copy of the Kill'ed
> file will NOT be in your Recycle Bin afterwards. I mention this because if
> you read the file in, then Kill it, and your system should crash before
> you save the spreadsheet, the data will be lost and the original text file
> will not be recoverable. You could consider using the FileCopy statement
> to copy the file into a Temp directory, then Kill it from its original
> location; that way, you could delete it with your regular Temp directory
> clean up sometime later on when you have safely saved the spreadsheet
> and/or backed up your system.
>
> Rick
>
>
> "Jeff W." <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> My work book prompts me for a txt file that I read data onto one of
>> my sheets to, and I want to delete this txt file after the read.
>>
>> I'm not sure how to do this, can anyone offer advice
>>
>> Thanks,
>>
>> Jeff W.
>>

>



 
Reply With Quote
 
Leith Ross
Guest
Posts: n/a
 
      13th Oct 2007
On Oct 13, 10:08 am, "Jeff W." <part_ma...@verizon.net> wrote:
> Thanks for the reply Rick, however I do understand the risks of data loss
> and the particular txt file is generated by another application, it isnt
> sensitive
> data or un replaceable data, so that wount be an issue.
>
> Can you show me exmaple of how to use the kill command to delete a txt file?
>
> Thanks,
>
> Jeff W.
>
> "Rick Rothstein (MVP - VB)" <rickNOSPAMn...@NOSPAMcomcast.net> wrote in
> messagenews:(E-Mail Removed)...
>
> > You could use VBA's Kill statement to remove the text file; however, you
> > should understand that the removal is permanent... a copy of the Kill'ed
> > file will NOT be in your Recycle Bin afterwards. I mention this because if
> > you read the file in, then Kill it, and your system should crash before
> > you save the spreadsheet, the data will be lost and the original text file
> > will not be recoverable. You could consider using the FileCopy statement
> > to copy the file into a Temp directory, then Kill it from its original
> > location; that way, you could delete it with your regular Temp directory
> > clean up sometime later on when you have safely saved the spreadsheet
> > and/or backed up your system.

>
> > Rick

>
> > "Jeff W." <part_ma...@verizon.net> wrote in message
> >news:(E-Mail Removed)...
> >> My work book prompts me for a txt file that I read data onto one of
> >> my sheets to, and I want to delete this txt file after the read.

>
> >> I'm not sure how to do this, can anyone offer advice

>
> >> Thanks,

>
> >> Jeff W.


Hello Jeff,

If the file isn't in the current directory you need to include the
full directory path with the file name and type.

Kill "Sample.txt"

Sincerely,
Leith Ross

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      13th Oct 2007
For future reference, you can type any VBA statement name, function name,
keyword, etc. into the code or Immediate window and, with the cursor next to
or in that word, press F1 for help on it. As for you example.... just
include the full path plus the filename as a String argument to it.

Using String Constant
==================
Kill "c:\folder1\folder2\etc\YourTextFile.txt"

Using String Variable
==================
Dim FilePathName As String
......
......
FilePathName = TextBox1.Text
Kill FilePathName


Rick


"Jeff W." <(E-Mail Removed)> wrote in message
news:%23$(E-Mail Removed)...
> Thanks for the reply Rick, however I do understand the risks of data loss
> and the particular txt file is generated by another application, it isnt
> sensitive
> data or un replaceable data, so that wount be an issue.
>
> Can you show me exmaple of how to use the kill command to delete a txt
> file?
>
> Thanks,
>
> Jeff W.
>
>
>
>
> "Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
>> You could use VBA's Kill statement to remove the text file; however, you
>> should understand that the removal is permanent... a copy of the Kill'ed
>> file will NOT be in your Recycle Bin afterwards. I mention this because
>> if you read the file in, then Kill it, and your system should crash
>> before you save the spreadsheet, the data will be lost and the original
>> text file will not be recoverable. You could consider using the FileCopy
>> statement to copy the file into a Temp directory, then Kill it from its
>> original location; that way, you could delete it with your regular Temp
>> directory clean up sometime later on when you have safely saved the
>> spreadsheet and/or backed up your system.
>>
>> Rick
>>
>>
>> "Jeff W." <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> My work book prompts me for a txt file that I read data onto one of
>>> my sheets to, and I want to delete this txt file after the read.
>>>
>>> I'm not sure how to do this, can anyone offer advice
>>>
>>> Thanks,
>>>
>>> Jeff W.
>>>

>>

>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Win2K SP4 and Error Deleting File or Folder. There has been a sharing violation. The source or destination file may be in use. Toni Fontenele Microsoft Windows 2000 File System 1 19th Nov 2010 08:47 PM
An Automated process of watching a network file folder, reading a file in it and deleting the file using ASP.NET ? Luis Esteban Valencia Muņoz Microsoft ASP .NET 3 4th Jun 2005 11:56 AM
Deleting a file location path under tools, options, file locations =?Utf-8?B?ZWpl?= Microsoft Word Document Management 1 11th Feb 2004 08:54 PM
Windows 2000 SP4 and Error Deleting File or Folder. There has been a sharing violation. The source or destination file may be in use. Toni Fontenele Microsoft Windows 2000 File System 0 5th Sep 2003 01:48 PM
Re: I am Back... Error Deleting File or Folder. There has been a sharing violation. The source or destination file may be in use. Toni Fontenele Microsoft Windows 2000 File System 0 27th Aug 2003 01:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:04 PM.