View Single Post
 
Old 08-19-2022, 10:45 PM
soroush.kalantari soroush.kalantari is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Jun 2021
Posts: 124
soroush.kalantari is on a distinguished road
Default Need help deleting some specific files by an Excel macro

I am trying to delete some specific PowerPoint files which are in a specific folder through following macro. But when running the code, it gives this error”File not found” on the line “Kill MyFiles”. As the attachment shows, the PowerPoint files are in the mentioned folder and by utilizing a MsgBox and clicking on the line which the error occurs, I have ensured that the code identifies the files but, for a unknown reason, it fails to delete them. Can you give me some guides on this issue?

Option Explicit
Sub deletepowepoint()

Dim MyFiles As String

MyFiles = Dir("D:\kalantari\miscellaneous\dailyreport01\*.pp tx")
Do While MyFiles <> "sample.pptx"

Kill MyFiles
MyFiles = Dir
Loop
End Sub
Attached Images
File Type: png Capture01.PNG (103.4 KB, 20 views)

Last edited by soroush.kalantari; 08-20-2022 at 06:54 PM.
Reply With Quote