Expand Minimize

DocumentBase.GetWorkflowTasks Method

Returns the workflow tasks that are assigned to the document.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)

public WorkflowTasks GetWorkflowTasks()

Return Value

Type: Microsoft.Office.Core.WorkflowTasks
A Microsoft.Office.Core.WorkflowTasks collection that contains the workflow tasks that are assigned to the document.

The following code example displays the number of workflow tasks that are currently associated with the document. The example then iterates through each workflow task, if any, and shows some selected task properties in a message box.

To add workflow tasks to your document, you must publish the document to an Office Sharepoint Server site. To use this example, run it from the ThisDocument class in a document-level project.

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);
    }
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft