Question

Locked

Programmatically delete a (Excel) file from Sharepoint Library

By net_prof ·
I'm having major problems deleting files from Sharepoint Library/directories using VBA (in Excel). I've tried both (VBA) Kill and fso.deletefile and nothing seems to work. In fact having problems with fso.FileExist and other fso methods (results act like file does not exist). I have no problems writing a file to the Sharepoint libraries or any associated actions using VBA (i.e. Workbooks().SaveAs, etc.)

Is there something else involved like using the Checkin/checkout functionality that I have missed? I tried to do an extensive search on the web for the past several days but am coming up with virtually nothing to cover deleting files.

Does anyone have ANY idea how to properly do this?? I need to use this for a current project and any immediate help or guidance is VERY MUCH APPRECIATED.

Thanks (a Million ahead of time),

Ken

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

This might give you more info..

http://msdn2.microsoft.com/en-us/library/aa973804.aspx

Please post back if you have more problems or questions.

Collapse -

Further explanation of what I'm trying to do...

by net_prof In reply to This might give you more ...

I reviewed your link, but I wasn't able to find anything that would help with what I am trying to do. Let me explain briefly what the process is:

The Excel application is for project tracking for a client. Sharepoint site has been set up with a different directory for each project step. Within the Excel app, the user must complete specific cells in the worksheet, then click (embedded) command button (different for each step) to initiate the next step. When the specific button is clicked, the excel application/workbook needs to be moved from one sharepoint library/directory to the next. I am able to use SAVEAS but can not remove or even rename the existing Excel workbook within the current directory.

I am trying to accomplish this using VBA within the spreadsheet because of time constraints. I would like to learn Excel Web Services for Sharepoint for future , but am against a tight deadline for this project.

Thanks,

Ken

Collapse -

Additional note regarding your response

by net_prof In reply to This might give you more ...

Additional note after further review of the link included in last response:

The link you referenced included the statement "The previous steps assume that you are building the Web Part on a computer where Office SharePoint Server 2007 is installed." The Sharepoint Server I am using is being hosted by another company and I do not have server level access. My group access level to the site is Reader and Contributor.

Collapse -

Then unless you give this to...

Whom is in control with the server, you will not be able to do what you need to do.

Please post back if you have more problems or questions.

Collapse -

Use SharedWorkspace Delete method to delete files from SharePoint

by david.l.desouza In reply to Programmatically delete a ...

'If nobody has the file checked out
If Workbooks.CanCheckOut("http://FilePath"") = True Then
Application.DisplayAlerts = False
'Open the file on the SharePoint server
Workbooks.Open Filename:="http://FilePath", UpdateLinks:=xlUpdateLinksNever
If Workbooks("Book1.xls").SharedWorkspace.Connected Then
'Delete the file on the SharePoint server
Workbooks("Book1.xls").SharedWorkspace.RemoveDocument
End If
'Close the workbook
Workbooks("Book1.xls").Close
Application.DisplayAlerts = True
Else
Application.DisplayAlerts = False
'Open the File to check if you already have it checked out
Workbooks.Open Filename:="http://FilePath", UpdateLinks:=xlUpdateLinksNever
'See if doc can be checked in
If Application.Workbooks("Book1.xls").CanCheckIn Then
'Check In, Save and Close
Application.Workbooks("Book1.xls").CheckIn SaveChanges:=True, Comments:="Checked-In before Delete"
'Open the file again
Workbooks.Open Filename:="http://FilePath"
If Workbooks("Book1.xls").SharedWorkspace.Connected Then
'Delete the file on the SharePoint server
Workbooks("Book1.xls").SharedWorkspace.RemoveDocument
End If
'Close the workbook
Workbooks("Book1.xls").Close
End If
End If

Collapse -

Problem with procedure

by KelbyRose In reply to Use SharedWorkspace Delet ...

When I use the supplied code, the macro stops at the first statement of 'Workbooks("Book1.xls").sharedworkspace.removedocument' and I get run-time error 5, with this message: 'Invalid procedure call or argument.' If I click Run again, the macro proceeds and deletes the file. Any idea what's causing the hiccup?

Collapse -

I have the same problem deleting Sharepoint docs with vba

by Bragmiester In reply to Programmatically delete a ...

I am most interested in if you found a solution to the problem of deleting a workbook file from sharepoint library with excel vba.

To date i have not found a solution.
Or be able to move a document from one folder to the next at the very least.
Any assistance you can offer would be appreciated. Thanks

Back to Software Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums