T Todd Huttenstine Nov 18, 2003 #1 I need to delete the file C:\Sheets.xls using VBA. How do I do this? Thank you Todd Huttenstine
D Dave Peterson Nov 18, 2003 #2 Take a look at the Kill command in Help. Todd said: I need to delete the file C:\Sheets.xls using VBA. How do I do this? Thank you Todd Huttenstine Click to expand...
Take a look at the Kill command in Help. Todd said: I need to delete the file C:\Sheets.xls using VBA. How do I do this? Thank you Todd Huttenstine Click to expand...
T Todd Huttenstine Nov 18, 2003 #3 Below is the code I used and its closing the file, not deleting the file. Kill "c:\sheets.xls"
T Todd Huttenstine Nov 18, 2003 #4 nevermind I got it. -----Original Message----- Take a look at the Kill command in Help. -- Dave Peterson (e-mail address removed) . Click to expand...
nevermind I got it. -----Original Message----- Take a look at the Kill command in Help. -- Dave Peterson (e-mail address removed) . Click to expand...
G Guest Nov 18, 2003 #5 Untested air code (needs reference to Microsoft Scripting Runtime Library [scrrun.dll]): Dim fso as FileSystemObject Dim f as File Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile("C:\Sheets.xls") f.Delete Set f = Nothing Set fso = Nothing Hope this helps! Jake ----- Todd Huttenstine wrote: ----- Below is the code I used and its closing the file, not deleting the file. Kill "c:\sheets.xls"
Untested air code (needs reference to Microsoft Scripting Runtime Library [scrrun.dll]): Dim fso as FileSystemObject Dim f as File Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile("C:\Sheets.xls") f.Delete Set f = Nothing Set fso = Nothing Hope this helps! Jake ----- Todd Huttenstine wrote: ----- Below is the code I used and its closing the file, not deleting the file. Kill "c:\sheets.xls"
P Pete McCosh Nov 18, 2003 #6 Todd, The Kill command wont work if you have the file you want to kill open, as I presume you must have, otherwise you couldn't close it! Pete
Todd, The Kill command wont work if you have the file you want to kill open, as I presume you must have, otherwise you couldn't close it! Pete
O onedaywhen Nov 18, 2003 #7 Jake said: Untested air code (needs reference to Microsoft Scripting Runtime Library [scrrun.dll]): Dim fso as FileSystemObject Dim f as File Click to expand... Change these declarations to 'As Object' and the reference is not needed.
Jake said: Untested air code (needs reference to Microsoft Scripting Runtime Library [scrrun.dll]): Dim fso as FileSystemObject Dim f as File Click to expand... Change these declarations to 'As Object' and the reference is not needed.
D Dave Peterson Nov 19, 2003 #8 Actually, you can kill that open workbook: This was posted by Jim Rech: Sub testme() With ThisWorkbook .Saved = True .ChangeFileAccess xlReadOnly Kill .FullName .Close False End With End Sub (make sure you have backups!)
Actually, you can kill that open workbook: This was posted by Jim Rech: Sub testme() With ThisWorkbook .Saved = True .ChangeFileAccess xlReadOnly Kill .FullName .Close False End With End Sub (make sure you have backups!)