Ejemplo 1: archivo de eliminación de vba
' Needs to add "Microsoft Scripting Runtime" reference to your file
Function FileExists(ByVal FileToTest As String) As Boolean
FileExists = (Dir(FileToTest) <> "")
End Function
Sub DeleteFile(ByVal FileToDelete As String)
If FileExists(FileToDelete) Then 'See above
' First remove readonly attribute, if set
SetAttr FileToDelete, vbNormal
' Then delete the file
Kill FileToDelete
End If
End Sub
Ejemplo 2: carpeta de eliminación de Excel vba
' Needs to add "Microsoft Scripting Runtime" reference to your file
Sub DeleteFolder(pFolder As String, pDeleteReadOnlyToo As Boolean)
Dim FSO As New FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.DeleteFolder pFolder, pDeleteReadOnlyToo
End Sub
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)