Microsoft KB Archive/161603

= TMGR: Clear, Copy, Cut, Delete, Paste Methods Return No Error =

Article ID: 161603

Article Last Modified on 8/17/2005

-

APPLIES TO


 * Microsoft Team Manager 1.0 Standard Edition

-



This article was previously published under Q161603



SYMPTOMS
The Paste method of the CurrentView object, and the Clear, Copy, Cut, and Delete methods of the Selection object return no errors when they fail.

When a macro in another application uses one of these methods to control Microsoft Team Manager, the macro cannot use error trapping to test if the method has failed.



WORKAROUND
To retrieve or edit data for tasks, people, or assignments, write the macro using the corresponding collections instead of using the Paste method of the CurrentView object and the Clear, Copy, Cut, and Delete methods of the Selection object. For example, the following macro displays the Start date of the task with ID 3, and then sets its Deadline to 2/1/97: Sub GetStartOfTask1 Set tm = GetObject(, "TeamManager.Application") MsgBox tm.Tasks(3).Start tm.Tasks(3).Deadline = "2/1/97" End The current view and selection have no affect using this approach.



STATUS
This behavior is by design.



MORE INFORMATION
All of the code in this article is assumed to be in another application, such as Microsoft Excel or Visual Basic.

The CurrentView object is accessed by applying the CurrentView method to the Window object. For example, the macro below displays the name of the current view in Microsoft Team Manager: Sub GetCurrentView Set TM = GetObject(, "TeamManager.Application") MsgBox TM.Window.CurrentView.Name End Sub The Selection Object is accessed by applying the Selection method to the CurrentView object. For example, the following macro displays the number of tasks in the current selection (an OLE Automation error occurs if a task table is not active): Sub HowManyTasksAreSelected Set TM = GetObject(, "TeamManager.Application") MsgBox TM.Window.currentview.Selection.Tasks.Count End Sub The Paste method of the CurrentView object and the Clear, Copy, Cut, and Delete methods of the Selection object behave differently, depending on the active view and selection. In some views, such as Missing Status Reports, these methods always fail. For example, if the Missing Status Reports view is currently active in Microsoft Team Manager, then the following macro fails to copy anything to the Clipboard, but returns no error: Sub test1 Set TM = GetObject(, "TeamManager.Application") TM.Window.CurrentView.Selection.Copy End Sub In some views, the success or failure of these methods depends on the active selection. For example, in the Task Organizer view, the Paste method fails without returning an error if the active selection is a cell in a read-only field, such as the task Start field.

Sometimes these methods cause Microsoft Team Manager to display a warning message or a prompt offering a choice of actions. For example, attempting to paste an invalid date into the Deadline field causes Microsoft Team Manager to display an invalid date message with Try Again and Clear It buttons. The Microsoft Team Manager window must be active to see the message, and the calling macro hangs while the message is displayed. The Paste method returns no error or value indicating which button is clicked.

The Paste method of the CurrentView object and the Clear, Copy, Cut, and Delete methods of the Selection object are very limited. To retrieve or edit specific fields in specific records, the macro must be written to work with a specific view and arrangement of columns. Whenever possible, write the macro using the tasks, people, and assignments collections instead.

