共用方式為


DocumentBase.Sync 屬性

取得 Sync 物件,此物件可用來存取 [文件工作區] 下的文件方法和屬性。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

語法

'宣告
Public ReadOnly Property Sync As Sync
    Get
public Sync Sync { get; }

屬性值

型別:Microsoft.Office.Core.Sync
Sync 物件,可用來存取 [文件工作區] 部分的文件方法和屬性。

範例

下列程式碼範例會判斷文件是否屬於文件工作區的一部分。 如果是,則程式碼會將事件處理常式附加到 SyncEvent 事件,該事件在同步處理失敗時會顯示訊息。 若要使用這個範例,請在文件層級專案中的 ThisDocument 類別執行。

Private Sub DocumentSyncAndSyncEvent()
    If Me.Sync.Status = Office.MsoSyncStatusType.msoSyncStatusNoSharedWorkspace Then
        MessageBox.Show("The document is not part of a " & "shared document workspace.")
        Return
    End If
    AddHandler Me.SyncEvent, AddressOf ThisDocument_SyncEvent
End Sub

Private Sub ThisDocument_SyncEvent(ByVal SyncEventType As Office.MsoSyncEventType)
    If SyncEventType = Office.MsoSyncEventType.msoSyncEventDownloadFailed _
        OrElse SyncEventType = Office.MsoSyncEventType.msoSyncEventUploadFailed Then
        MessageBox.Show("Document synchronization failed. " & _
            "Please contact your administrator.")
    End If

End Sub
private void DocumentSyncAndSyncEvent()
{
    if (this.Sync.Status ==
        Office.MsoSyncStatusType.msoSyncStatusNoSharedWorkspace)
    {
        MessageBox.Show("The document is not part of a " +
            "shared document workspace.");
        return;
    }

    this.SyncEvent +=
        new Word.DocumentEvents2_SyncEventHandler(
        ThisDocument_SyncEvent);
}

void ThisDocument_SyncEvent(Office.MsoSyncEventType SyncEventType)
{
    if (SyncEventType ==
        Office.MsoSyncEventType.msoSyncEventDownloadFailed ||
        SyncEventType ==
        Office.MsoSyncEventType.msoSyncEventUploadFailed)
    {
        MessageBox.Show("Document synchronization failed. " +
            "Please contact your administrator.");
    }
}

.NET Framework 安全性

請參閱

參考

DocumentBase 類別

Microsoft.Office.Tools.Word 命名空間