PRB: Executing Quit Method on OLE Object Quits VFP (156751)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q156751 SYMPTOMS
When you reference the Application property to Quit an OLE object, Visual
FoxPro terminates. This article illustrates how to remove or hide an OLE
Chart object and explains how the Application property behaves with OLE
objects.
CAUSE
Each Visual FoxPro object has an Application property that refers to the
Visual FoxPro application object. Because that object has a Quit method,
invoking that method terminates the Visual FoxPro session.
The Application property refers to the Visual FoxPro object, not the object
in the OLE control. The Help file topic concerning the Application Property
states:
Provides a reference to the Application object containing an object.
In this case, the Application object is Visual FoxPro.
WORKAROUND
Since an Excel chart object does not have a Quit property, you must use
properties available in Visual FoxPro. First, if you want to remove the
object from the form, call the RemoveObject method of the form. For
example:
frmMyForm.RemoveObject('oletest')
This removes the object from the form without quitting Visual FoxPro.
Second, if you simply need to hide the OLE object, set the Visible property
of the object to false (.F.). For example:
frmMyForm.oletest.Visible=.T.
The method you choose depends on whether you need to access the
OLEContainer again. Toggling the Visible property between True and False is
faster than invoking the AddObject method. However, if you truly want to
remove the object from the form, the RemoveObject method is preferable.
STATUS
This behavior is by design.
REFERENCES
For more information about properties and methods available to the
Application Object, search for "Application Object" and then "Properties"
or "Methods" in the Visual FoxPro Help file. Also see the following
articles in the Microsoft Knowledge Base:
156548 How To Use the object Property to Reference Methods/Properties
155747 How To Use the New Application Property in VFP 5.0
For more information about Excel's Object Browser, please see the following
article in the Microsoft Knowledge Base:
142128 XL: How to Find Visual Basic for Application Help
Modification Type: | Major | Last Reviewed: | 10/15/2003 |
---|
Keywords: | KB156751 kbAudDeveloper |
---|
|