Hi All
Having done some research, I have found out to delete a file in VBA you use the Kill command.
However when doing this, I get a message File not Found
my code is:
Code
Dim MyPath As String
Dim DestPath As String
Dim MyFile As String
Dim MyExt As String
Dim wb As Workbook
MyPath = "C:\Users\Owner\Dropbox\Accounts Miqlat\" 'to change in live (no "Test1")
DestPath = "C:\Users\Owner\Dropbox\Accounts Miqlat\Test\" 'to change in live
MyExt = "*.xlsx"
MyFile = Dir(MyPath & MyExt)
'Do Until MyFile <> "*Cash Management*"
Do Until MyFile = ""
If MyFile Like "*Cash Management*" Then
Set wb = Workbooks.Open(FileName:=MyPath & MyFile)
wb.Close
Kill MyFile
Display More
When I step through the code, it happily opens the file, and knows the name of MyFile at the point of kill.
Please can someone advise what step I might be missing?
Thanks