1

I am having a excel workbook. When a person click on the marco the files are saves to two new folders need to delete a Excel file on SharePoint.

I have tried the "Kill" function in Excel VBA, but is says the file do not exist.

Kill function

Sub DeleteExample3()
'You can use this to delete one xls file in the folder Test
    On Error Resume Next
    Kill "C:\Users\Ron\Test\ron.xls"
    On Error GoTo 0
End Sub

Do any one have success or a example by killing a file using VBA?!

Thanks

2 Answers 2

1

First your code sample points to a file locally stored on a hard drive, not a SharePoint file.

I'm not an expert in VBA but if you want to delete a SharePoint file from within an Excel file (=client application) I would use/call the SharePoint web services. You can delete a file from a SharePoint list using the lists.asmx web service http://{yourserver}/_vti_bin/lists.asmx

Make sure that the user has delete permissions in SharePoint

1
  • HI W0ut, It is correct that correct that i want's to delete a SharePoint file by clicked a macro in a Excel file. I will look into lists.asmx, and see if this is possible.
    – boje
    Commented Sep 8, 2012 at 8:05
1

easiest way is to map a network drive to the sharepoint folder

Dim spMap As Object, spPath As String

Set spMap = CreateObject("WScript.Network")
spMap.MapNetworkDrive "X:", spPath
DoEvents

Kill "X:\Book1.xls"

spMap.RemoveNetworkDrive "X:", True

checking to see if it exists is a whole other matter...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.