CanCheckOut Method

Microsoft Excel Visual Basic

expression.CanCheckOut(FileName)

expression    Required. An expression that returns one of the objects in the Applies To list.

FileName   Required String. The name of the file to check out.

Example

This example verifies that a workbook is not checked out by another user and can be checked out. If the workbook can be checked out, it copies the workbook to the local computer for editing.

Sub UseCanCheckOut(docCheckOut As String)

    ' Determine if workbook can be checked out.
    If Workbooks.CanCheckOut(Filename:=docCheckOut) = True Then
        Workbooks.CheckOut (Filename:=docCheckOut)
    Else
        MsgBox "You are unable to check out this document at this time."
    End If

End Sub