Name

workbooks.CanCheckOut(Filename)

Synopsis

For workbooks that are part of a shared workspace, verifies that the workbook is available to be checked out. Use CanCheckOut to verify that the file is available before calling the CheckOut method.

Argument

Settings

Filename

The address of the file on the SharePoint server for which to verify the status

Returns True if the current user can check out a shared workbook from the SharePoint server. Returns False if the workbook cannot be checked out. Causes an error if the SharePoint server or file can’t be found.

The following code checks out a file from a SharePoint server, first verifying that it is available:

fil = "//wombat2/Team Wombat/Shared Documents/ch08.xls"
If Application.Workbooks.CanCheckOut(fil) Then
    Application.Workbooks.CheckOut (fil)
    Set wb = Application.Workbooks.Open(fil)
    If wb.SharedWorkspace.Connected Then _
        msg = "ch08.xls is check out to you."
Else
    msg = "ch08.xls could not be checked out."
End If
MsgBox msg

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.