Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Night Owl
 
Posts: n/a
Default Deleting a file from within Excel

Hi,

I'm importing data from an external *.txt file, but don't want to duplicate
the data by importing the same file twice. When I'm doing it I'll remember
to delete the file after I've imported it, but when someone else does it
they may not.

So my question is this...

The filename and path are stored in the variable myFile - How can I delete
this file as the final step in the macro, without being prompted by a yes/no
option?

As an aside, I also get a prompt when I try to delete a non-active sheet
using code. Can I prevent that, too?

TIA,

Pete


  #2   Report Post  
Alan
 
Posts: n/a
Default

Try
Application.DisplayAlerts=False
'Your Filename'.Delete
Application.DisplayAlerts=True
Regards,
Alan.
"Night Owl" wrote in message
...
Hi,

I'm importing data from an external *.txt file, but don't want to
duplicate the data by importing the same file twice. When I'm doing it
I'll remember to delete the file after I've imported it, but when someone
else does it they may not.

So my question is this...

The filename and path are stored in the variable myFile - How can I delete
this file as the final step in the macro, without being prompted by a
yes/no option?

As an aside, I also get a prompt when I try to delete a non-active sheet
using code. Can I prevent that, too?

TIA,

Pete



  #4   Report Post  
Night Owl
 
Posts: n/a
Default

Thanks, William.

I'm sorted,

Pete

"William" wrote in message
...
Hi Pete

Sub test()
'Assumes full path of file name
'to be deleted is in cell B2 and
'the file has been closed
Dim myFile As String
myFile = ThisWorkbook.Sheets("Sheet1").Range("B2")
Kill myFile
End Sub

Sub test1()
Application.DisplayAlerts = False
ThisWorkbook.Sheets("Sheet1").Delete
Application.DisplayAlerts = True
End Sub


--


XL2003
Regards

William



"Night Owl" wrote in message
...
Hi,

I'm importing data from an external *.txt file, but don't want to
duplicate the data by importing the same file twice. When I'm doing it
I'll remember to delete the file after I've imported it, but when someone
else does it they may not.

So my question is this...

The filename and path are stored in the variable myFile - How can I
delete this file as the final step in the macro, without being prompted
by a yes/no option?

As an aside, I also get a prompt when I try to delete a non-active sheet
using code. Can I prevent that, too?

TIA,

Pete





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
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
Saved *.csv file gives SYLK file type warning upon Excel 2003 open Tom Excel Discussion (Misc queries) 5 March 19th 08 03:15 PM
2003 Excel isn't reading the book.xlt file on startup. rlweaver007 Excel Discussion (Misc queries) 1 March 15th 05 09:26 AM
Locating a file in excel with a partial file name. Audra Excel Discussion (Misc queries) 2 February 19th 05 08:52 PM
save excel file from a table delimited file (.txt) using macros sedamfo New Users to Excel 1 February 15th 05 04:19 AM


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