Workbook.GetWorkflowTasks Method (2007 System)

Returns the collection of workflow tasks for the workbook.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
Public Function GetWorkflowTasks As WorkflowTasks
'Usage
Dim instance As Workbook 
Dim returnValue As WorkflowTasks 

returnValue = instance.GetWorkflowTasks()
public WorkflowTasks GetWorkflowTasks()
public:
WorkflowTasks^ GetWorkflowTasks()
public function GetWorkflowTasks() : WorkflowTasks

Return Value

Type: WorkflowTasks
A Microsoft.Office.Core.WorkflowTasks collection that contains the workflow tasks for the workbook.

Examples

The following code example displays the number of workflow tasks that are currently associated with the workbook. 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 workbook, you must publish the workbook to an Office Sharepoint Server 2007 site.

This example is for a document-level customization.

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 Security

See Also

Reference

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace