TMGR: Misuse of File Property May Result in Error Message. (155553)



The information in this article applies to:

  • Microsoft Team Manager

This article was previously published under Q155553

SUMMARY

You cannot use the Microsoft Team Manager Application object's read-only File property to change the name of the active team file. Attempting to do so results in an error message. Depending on the syntax you use, it may result in a misleading error message. For example, if the following macro is run from an application that supports Visual Basic for Applications macros, it results in a "Type Mismatch" error:
    Sub Test()
        Dim oTmgr As Object
        Set oTmgr = GetObject(, "TeamManager.Application")
        oTmgr.File "My File"
    End Sub
				

MORE INFORMATION

The Application's read-only File property returns a File object. The default property of a File object is its read-only Name property. Assuming that oTmgr refers to the Team Manager Application object, the table below shows various incorrect uses of File and Name and the resulting error messages:
    Macro Line                     Error Message
    ----------                     -------------
    oTmgr.File "My File"           Type mismatch
    oTmgr.File.Name "My File"      Unable to write read-only property
    -----------------------------------------------------------------
    oTmgr.File = "My File"         Unable to write read-only property
    oTmgr.File.Name = "My File"    Unable to write read-only property
    -----------------------------------------------------------------
    oTmgr.File                     Argument not optional
    oTmgr.File.Name                Argument not optional
				
Because Name is the default property of the File object, the line
    oTmgr.File "My File"
				
should produce the same error message as the line:
    oTmgr.File.Name "My File"
NOTE: The correct way for a macro to rename the current team file is to save it out with a different name using the Application object's SaveAs method. For example:
    Sub Test()
        Dim oTmgr As Object
        Set oTmgr = GetObject(, "TeamManager.Application")
        oTmgr.SaveAs "C:\My File"
    End Sub
				

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbdtacode kberrmsg kbProgramming KB155553 kbAudDeveloper