Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Deleting a txt file after reaqing it

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Deleting a txt file after reaqing it

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." wrote in message
...
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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Deleting a txt file after reaqing it

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)" wrote in
message ...
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." wrote in message
...
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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Deleting a txt file after reaqing it

On Oct 13, 10:08 am, "Jeff W." 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)" wrote in
. ..

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." wrote in message
...
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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Deleting a txt file after reaqing it

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." wrote in message
...
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)" wrote in
message ...
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." wrote in message
...
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
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
Deleting a file Jo[_3_] Excel Discussion (Misc queries) 1 March 29th 09 02:50 AM
deleting a file Abhishek kedia Excel Discussion (Misc queries) 1 April 22nd 06 02:49 PM
deleting file(s) by their file extension jt46[_4_] Excel Programming 3 October 13th 04 07:54 PM
Deleting file while in use Todd Huttenstine Excel Programming 1 April 29th 04 07:39 PM
Deleting a file using VB Rohit Thomas Excel Programming 3 July 14th 03 09:11 PM


All times are GMT +1. The time now is 10:18 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"