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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。