LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Error in a "Kill" command

Thanks Chip. That's good information to have. Otto
"Chip Pearson" wrote in message
...

One note, in case you were not aware, Kill performs a non-recoverable
deletion of the file... it does NOT delete to the Recycle Bin.


And code to send a file or folder to the Recycle Bin can be found at
http://www.cpearson.com/Excel/Recycle.aspx.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"Rick Rothstein (MVP - VB)" wrote in
message ...
Since the path is OK, you would just delete them as normal files. You
could do them one at a time...

Kill ThePathDocs & "One.doc"
Kill ThePathDocs & "Two.doc"
Kill ThePathDocs & "Three.doc"

or via the Array function as you originally tried to do....

For Each TheFile In Array("One.doc", "Two.doc", "Three.doc")
Kill ThePathDocs & TheFile
Next

One note, in case you were not aware, Kill performs a non-recoverable
deletion of the file... it does NOT delete to the Recycle Bin.

Rick


"Otto Moehrbach" wrote in message
...
Rick
The path does end in a backslash. Dave pointed out that the word
"Workbooks" and a Word file name (xxx.doc) do not go together, and
that's obvious now that he has pointed it out.
I have 3 Word files, none of which are open, and I want to remove
them from disk (hence the Kill command). Any help you can provide with
the code would be appreciated. Thanks again. Otto
"Rick Rothstein (MVP - VB)" wrote
in message ...
I'm do not see why you have to change the file access to Read Only in
order to delete it, but that shouldn't be your error either. My first
thought is that ThePathDocs variable does **not** end in a backslash
(so that when you concatenate it with TheFile, the resulting filename
is an ugly combination of the last folder in the path and the actual
filename).

Rick


"Otto Moehrbach" wrote in message
...
Excel XP & Win XP
In this snippet of code I am trying to "Kill" 3 files. I get a
"Subscript out of range" error on the "Kill" command with the first
file. So I changed the order of the files in the "For Each.." line and
again I get that error with the first name. This tells me that the
problem is with the "Kill" line. The "ThePathDocs" is the path to the
folder that holds the files. What did I do wrong? Thanks for your
time. Otto

For Each TheFile In Array("One.doc", "Two.doc", "Three.doc")
Workbooks(ThePathDocs & TheFile).ChangeFileAccess xlReadOnly
Kill Workbooks(ThePathDocs & TheFile).FullName








 
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
ie Command to Wait for "File Download" and "Save As" windows [email protected] Excel Programming 11 April 24th 08 11:20 AM
XLL and "New Form" command error nicgendron[_3_] Excel Programming 0 August 15th 05 01:57 PM
FileCopy Command Giving "Subscript Out of Range" Error Message Jim Hagan Excel Programming 2 June 15th 05 06:07 PM
Exel2000 VBA - Creating a Command Bar - Error: "Object Variable or With not Set" keepitcool Excel Programming 0 August 11th 03 12:29 PM


All times are GMT +1. The time now is 08:48 PM.

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

About Us

"It's about Microsoft Excel"