Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

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

share|improve this answer
    
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 Sep 8 '12 at 8:05

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...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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