Answers for "vba to delete files in a folder"

VBA
1

vba delete file

' 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
Posted by: Guest on January-31-2021
0

excel vba delete folder

' 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
Posted by: Guest on March-21-2021

Code answers related to "vba to delete files in a folder"

Code answers related to "VBA"

Browse Popular Code Answers by Language