Bewerken

Delen via


Workbook.CheckInWithVersion method (Excel)

Saves a workbook to a server from a local computer, and sets the local workbook to read-only so that it cannot be edited locally.

Syntax

expression.CheckInWithVersion (SaveChanges, Comments, MakePublic, VersionType)

expression A variable that returns a Workbook object.

Parameters

Name Required/Optional Data type Description
SaveChanges Optional Variant True to save the workbook to the server location. The default is True.
Comments Optional Variant Comments for the revision of the workbook being checked in (applies only if SaveChanges is set to True).
MakePublic Optional Variant True to allow the user to publish the workbook after it is checked in.
VersionType Optional Variant Specifies versioning information for the workbook.

Return value

Nothing

Remarks

Setting the MakePublic parameter to True submits the workbook for the approval process, which can eventually result in a version of the workbook being published to users with read-only rights to the workbook (applies only if SaveChanges is set to True).

To take advantage of the collaboration features built into Microsoft Excel, documents must be stored on a Microsoft SharePoint Server.

Example

The following example uses the CanCheckIn method to determine whether the workbook has been stored on a Microsoft SharePoint Server. If the workbook has been stored on a server, the example calls the CheckInWithVersion method to check in the workbook along with the specified comments and version number, save changes to the server location, and submit the workbook for the approval process.

This example is for a workbook-level customization.

Private Sub WorkbookCheckIn() 
  If ThisWorkbook.CanCheckIn Then 
    ThisWorkbook.CheckInWithVersion True, "Changed sheet 1 and 2 etc...", True, XlCheckInVersionType.xlCheckInMinorVersion 
  Else 
    Msgbox "This workbook cannot be checked in"
  End If 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.