VBA Checkout Workbook from SharePoint - Cannot Checkout this Document

walexnelson2

New Member
Joined
Sep 4, 2013
Messages
2
I have a local macro that pulls down workbooks from a remote SharePoint server that requires documents to be checked out before editing. So far I've been able to access the documents without issue which lets me know that the paths are correct at least - but it's always "Ready Only".

Here is an example of what I'm attempting to do. Based on the hours that I've spent searching the web, this little snippet of code should work without issue but it never gets past the IF statement because I "cannot checkout this document". I then thought perhaps it was permissions on the document itself in SharePoint, but I double checked and I have full permissions. I'm also able to manually check the documents out and check them back in.

The SharePoint is a secure (HTTPS) server, could that cause any issues checking a doc out? I've tried other ways to get the document out for editing, but I don't think I can get around the SharePoint library requirement to have documents checked out before editing.

I'm out of ideas. Anyone have any suggestions? And yes, I've double checked and the document is checked in on SharePoint.

Code:
'Example calling of function
URL = //SharePoint_Server/Directory/workbook.xlsx
set wb = CheckOutWorkbook(URL)

Function CheckOutWorkbook(sPath As String) As Workbook
    Dim wbWorkBook As Workbook
    
    If Workbooks.CanCheckOut(sPath) = True Then
        
        'Checkout Workbook for Editing
        Workbooks.CheckOut sPath
        
        'Open Workbook
        Set wbWorkBook = Workbooks.Open(sPath, , False)
        
        'Return Workbook
        Set CheckOutWorkbook = wbWorkBook
        
    Else
        MsgBox ("Unable to checkout the workbook at this time")
        End
    End If

End Function

Thanks in advance.

Excel 2007
 
Last edited:

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I figured it out. I have no idea how this happened or how I would recreate it, but while I was messing around with my code I caused an instance of Excel to remain open with that workbook (but I could only see it in running processes in the task manager where there were multiple Excel processes). I stopped the processes and now I can check out the workbook.

Not sure why I was still able to check the workbook out manually even though this invisible process was running on my machine... but that's a question for another time I guess.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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
Back
Top