View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Deleting another workbook through code

If you save it under a new name and just want to delete the old one, use

Kill oldFilepathandname

If you want to delete the activeworkbook

On Error GoTo ErrorHandler
With ActiveWorkbook
If .Path < "" Then
.Saved = True
.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
End If
End With
Exit Sub

ErrorHandler:
MsgBox "Fail to delete file: " & ActiveWorkbook.FullName
Exit Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"funkymonkUK" wrote
in message ...

Hi

I got a userform which askes the user to open up a file. i have stored
the value as a string. is there a way I can delete that file?

I have a workbook which is sent out to many users. I now want to
produce an updated version and delete the old workbook.

any ideas?


--
funkymonkUK
------------------------------------------------------------------------
funkymonkUK's Profile:

http://www.excelforum.com/member.php...o&userid=18135
View this thread: http://www.excelforum.com/showthread...hreadid=512228