Deleting all Files within a Sharepoint Folder Location

mnty89

Board Regular
Joined
Apr 1, 2016
Messages
66
Below is my current code which worked perfectly fine when the file was saved on my local drive. Now that I have migrated to all sharepoint versions of this it doesn't seem to work. All of the files remain in the sharepoint folder even after the macro has run. I have delete privledges within the sharepoint. I think something is just missing, or the method I'm using doesn't translate into sharepoint?

Is anyone familiar with this and can help?

The code essentially goes to the place where the workbook is stored, then into the folder "Files" and deletes all contents of that folder.

Sub DeleteOldFiles()


'Will delete all files within saved folder for old files
Dim xPath As String
xPath = Application.ActiveWorkbook.Path & "\Files\*.*"




On Error Resume Next
Kill xPath
On Error GoTo 0

MsgBox ("Deleted")
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,195,655
Messages
6,010,939
Members
441,577
Latest member
Alonshow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top