0

I've written a VBA program to examine each Excel workbook in a SharePoint folder and perhaps move it to another location. It turns out that rarely (but not never) a user is currently editing a workbook even though it's already completed and ready to be moved; presumably the owner is making last-minute changes. In that case my program, all unawares, moves the workbook to another folder and the user subsequently saves it. The result is two copies of the workbook, whereupon Bad Things happen.

So I'd like the program, as part of its examination of each workbook, to be able to determine whether the file is currently checked out. I've heard there's some sort of object model for SharePoint, and from what I read here it must be true. So I'd like one or maybe two answers:

Second preference: How can I determine in a VBA program whether a SharePoint file is currently checked out? I've seen very similar questions answered here, but they assumed a knowledge of the SP object model that I don't possess; I need to start from the creation of a SharePoint object.

First preference: Where can I find documentation on a SharePoint class I can use in VBA?! I keep seeing references to it but can't seem to find the starting point.

0

If you are running your VBA code within the an Excel application, then you can use the CanCheckOut property of the Workbooks collection in the Excel object model.

Workbooks.CanCheckOut(Path) will return true if a workbook is checked out, in which case you could avoid copying it.

That may give you a quick solution if you are in Excel and if you have the full path of the files, but might not be the ultimate preferred solution depending on what else you have going on.

I don't know how to do this directly through a Sharepoint object model or API but would also be interested in seeing such a solution.

  • That'll work, I think; I didn't know about that property, but I'll try it ... if only the user runs into the problem again. So far she's content with my workaround, but I'm eager to try this. – Bob Bridges Apr 18 '16 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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