TMGR: CreateObject Starts Team Manager with No Open File (161339)
The information in this article applies to:
This article was previously published under Q161339 SYMPTOMS
The CreateObject function starts a new windowless instance of Microsoft
Team Manager with no open file, even if the "Open last file at startup"
setting is selected. While no file is open, any attempt to use a property
or method of the TeamManager.Application object, except the New or Open
methods, results in an OLE Automation error.
WORKAROUNDMethod 1
After using CreateObject to start Microsoft Team Manager, use the New or
Open method to create or open a team file before using any other methods or
properties.
Method 2
Use the GetObject function with a specific file name to start Microsoft
Team Manager and open the specified team file.
Method 3
To start Microsoft Team Manager and automatically open the last file (the
file most recently opened), use the Shell function. This works only if the
"Open last file at startup" setting is selected and Microsoft Team Manager
is not already running. After the Shell function, use the GetObject
function to control Microsoft Team Manager with OLE Automation.
STATUS
This behavior is by design.
MORE INFORMATION
All of the following code is assumed to be in another application, such as
Microsoft Excel or Visual Basic.
The following line of code starts a windowless instance of Microsoft Team
Manager with no file open, not even a new blank file, and ignores the "Open
last file at startup" setting:
Set oTM = CreateObject("TeamManager.Application")
This is equivalent to:
Set oTM = GetObject("","TeamManager.Application")
While no file is open, no method or property of the TeamManger.Application
object can be used except the New and Open methods. For example, the
following macro causes an OLE Automation error:
Sub Sub1( )
Set oTM = CreateObject("TeamManager.Application")
MsgBox oTM.Name '<---Causes OLE Automation error
End Sub
Using the New or Open Method
The New method can be used to create a new team file. For example, the
following macro starts Microsoft Team Manager, and then creates a new team
file and saves it as File2.mtp in the folder C:\Myfiles:
Sub Sub2( )
Set oTM = CreateObject("TeamManager.Application")
oTM.New No, "C:\MyFiles\File2.mtp"
End Sub
NOTE: The first argument in the New method determines whether changes to
the active team file should be saved before creating the new file. It is
irrelevant in the above example because there isn't any active team file.
The Open method can be used to open an existing file. For example, the
following macro starts Microsoft Team Manager, and then opens the specified
file:
Sub Sub3()
Set oTM = CreateObject("TeamManager.Application")
oTM.Open No, "C:\MyFiles\File3.mtp"
End Sub
Using GetObject to Open a Specific File
GetObject can be used with a specific file name to start Microsoft Team
Manager and open the specified file. For example, if Microsoft Team Manager
is not running, the following line of code starts it and opens the
specified file:
Set oTM = GetObject("C:\MyFiles\File1.mtp")
Opening the Last File
The "Open last file at startup" setting can be accessed in Microsoft Team
Manager as follows: On the Tools menu, click Options, and then click the
General tab. The state of this setting is stored in the Windows registry,
along with the path and name of the last file (the file most recently
opened). If this setting is selected, the last file is automatically opened
when Microsoft Team Manager starts, provided it is not started using OLE
Automation.
OLE Automation cannot be used to start Microsoft Team Manager and
automatically open the last file, and there is no property or method that
will return the path and name of the last file.
The Shell function can be used to start Microsoft Team Manager and
automatically open the last file, provided that the "Open last file at
startup" setting is selected and Microsoft Team Manager is not already
running. After the Shell function, the GetObject function can be used to
control Microsoft Team Manager with OLE Automation. For example:
h = Shell ("C:\Program Files\Microsoft Team Manager\Teammgr.exe", 3)
Set oTM = GetObject(,"TeamManager.Application")
REFERENCES
For additional information about using OLE Automation with Microsoft
Team Manager, see the file TM1VBA.WRI located in the same folder as
the Microsoft Team Manager application.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbdtacode kberrmsg kbprb KB161339 |
---|
|