Checkout/in Excel Workbooks from SharePoint with VBA

0

I have found several articles and past questions in SO that help with this, but I have added a twist. I found a way to map a network drive on my PC to the SharePoint folders. If I open a workbook that is currently checked out I get the popup to choose read-only/notify/cancel. But if the workbook is not currently checked out, there is nothing that allows me to check it out (when I open it through the drive mapping) to prevent others from making changes. Is there a way to do this with VBA?

Iron Man

Posted 2016-02-03T18:39:51.913

Reputation: 101

Are you targeting the book to open from a different book? Are you using the Workbooks.Open method? – Raystafarian – 2016-02-04T15:11:21.903

@Raystafarian I need to call this from an Add-In that I created. This add-in contains a menu system and is used by a file that is created when we export data from our reporting system. The add-in (and this will sound familiar to you Raystafarian) would be used to check out and open the file located on SharePoint and the code will copy data from the import to the Swivel file. I have not tried anything yet for a couple of reasons: 1) I cannot find anything that seems to fit what I need. All articles that I have read have lots of comments from people who have had issues with checking out files. – Iron Man – 2016-02-04T15:27:26.597

@Raystafarian and 2) I am not sure if this can be done with the mapped drive, or if it will only function properly by going directly through the SP site itself. I am thinking the latter since I can open a file from SP through the drive mapping but do not have the option of checking out the file. – Iron Man – 2016-02-04T15:29:12.780

Answers

0

You should be able to check it with CanCheckOut method

If Workbooks.CanCheckOut(Filename) Then Workbooks.CheckOut (Filename)

KB CanCheckOut

KB CheckOut

Raystafarian

Posted 2016-02-03T18:39:51.913

Reputation: 20 384