View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default save and delete a file when in it with code

Hi Damien

You can kill a open file by changing the ChangeFileAccess

See how I do it here
http://www.rondebruin.nl/mail/folder1/mail2.htm



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Damien" wrote in message ...
I need to be able to kill a file once I have saved a copy of it to it's new
location.

I can save a copy from within the file and I can kill it from my desktop
(executing the same code) . When I go to kill from within the folder I get a
Permission Denied (Error 70) appearing. I am the owner / creator of the
folders and have full control of them. I can delete anything with mouse
clicks but not with code from within the folder.
The code I am using is as follows:

Sub DeletethenSaveFile()

Folderdetails = " Filepath and Name"

ThisWorkbook.SaveCopyAs "New Filepath and Name"
MsgBox "Your file has been saved to it's new location"

On Error Resume Next
Kill Folderdetails '"Filepath and Name"
MsgBox "The requested file has been deleted"
MsgBox "This file will now close"
ThisWorkbook.Close SaveChanges = False


End Sub

Please help me!!! D