DocumentBase.SyncEvent 事件
當屬於文件工作區一部分的文件之本機複本與伺服器上的複本同步處理時發生。
命名空間: Microsoft.Office.Tools.Word
組件: Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)
語法
'宣告
Public Event SyncEvent As DocumentEvents2_SyncEventHandler
public event DocumentEvents2_SyncEventHandler SyncEvent
範例
下列程式碼範例會判斷文件是否屬於文件工作區的一部分。 如果是,則程式碼會將事件處理常式附加到 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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。