DocumentBase.GetWorkflowTasks 方法

返回指派给文档的工作流任务。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word.v4.0.Utilities(在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)

语法

声明
Public Function GetWorkflowTasks As WorkflowTasks
public WorkflowTasks GetWorkflowTasks()

返回值

类型:Microsoft.Office.Core.WorkflowTasks
一个 Microsoft.Office.Core.WorkflowTasks 集合,包含分配给文档的工作流任务。

示例

下面的代码示例将显示当前与文档关联的工作流任务的数目。 然后,该示例将循环访问每个工作流任务(如果有),并在消息框中显示选定的某些任务属性。

若要在文档中添加工作流任务,必须将该文档发布到 Office Sharepoint Server 网站。 若要使用此示例,请从文档级项目内的 ThisDocument 类中运行此示例。

Private Sub DisplayWorkflowTasks()
    Dim tasks As Office.WorkflowTasks = Me.GetWorkflowTasks()
    If tasks.Count > 1 Then
        MessageBox.Show("There are " + tasks.Count.ToString() _
            + " workflow tasks.")
    ElseIf tasks.Count = 1 Then
        MessageBox.Show("There is " + tasks.Count.ToString() _
            + " workflow task.")
    ElseIf tasks.Count = 0 Then
        MessageBox.Show( _
            "No workflow tasks are associated with this document.")
    End If
    For Each task As Office.WorkflowTask In tasks
        MessageBox.Show( _
            "Workflow Task ID: " + task.Id _
            + vbCrLf + "Workflow Task Name: " + task.Name _
            + vbCrLf + "Assigned To: " + task.AssignedTo _
            + vbCrLf + "Description: " + task.Description)
    Next
End Sub
private void DisplayWorkflowTasks()
{
    Office.WorkflowTasks tasks = this.GetWorkflowTasks();
    if (tasks.Count > 1)
    {
        MessageBox.Show("There are " + tasks.Count.ToString() 
            + " workflow tasks.");
    }
    else if (tasks.Count == 1)
    {
        MessageBox.Show("There is " + tasks.Count.ToString() 
            + " workflow task.");
    }
    else if (tasks.Count == 0)
    {
        MessageBox.Show(
            "No workflow tasks are associated with this document.");
    }
    foreach (Office.WorkflowTask task in tasks)
    {
        MessageBox.Show(
            "Workflow Task ID: " + task.Id
            + "\r\nWorkflow Task Name: " + task.Name
            + "\r\nAssigned To: " + task.AssignedTo
            + "\r\nDescription: " + task.Description);
    }
}

.NET Framework 安全性

请参见

参考

DocumentBase 类

Microsoft.Office.Tools.Word 命名空间