Creates an object from a class definition or an Automation-enabled application.

CREATEOBJECT(cClassName [, eParameter1, eParameter2, ...])

Parameters

ClassName

Specifies the class or OLE object from which the new object is created. Visual FoxPro searches for the class or OLE object in the following order:

  1. Visual FoxPro base classes

  2. Classes in the current program

  3. Classes in .vcx class libraries opened with SET CLASSLIB

  4. Classes in procedure files opened with SET PROCEDURE

  5. Classes in the Visual FoxPro program execution chain

  6. The OLE registry if SET OLEOBJECT is ON

OLE objects are created using the following syntax for ClassName:

 CopyCode imageCopy Code
ApplicationName.Class

For example, to create a Microsoft Excel worksheet (which supports Automation), you can use the following syntax:

 CopyCode imageCopy Code
x = CREATEOBJECT('Excel.Sheet')

When this code is run, Microsoft Excel is started (if not already running), and a new worksheet is created.

A class library can have an alias. To specify an object in a class library with an alias, include the class library alias followed by a period and the object name.

Note that ClassName cannot be the Visual FoxPro OLE Container control base class.

eParameter1, eParameter2, ...

These optional parameters are used to pass values to the Init event procedure for the class. The Init event is executed when you issue CREATEOBJECT( ) and allows you to initialize the object.

Expand imageReturn Value

Expand imageRemarks

Expand imageExample

Expand imageSee Also