Condividi tramite


DoVerb Method

Executes a verb on the specified object.

Object.DoVerb[(Verb)]

Parameters

  • Verb
    The verb to execute on the object within the OLE container control. If not specified, the default verb is executed. The value of this argument can be one of the standard verbs supported by all objects or an index of the ObjectVerbs property array. Each object can support its own set of verbs.

    The following values represent standard verbs supported by every object:

    Value Action
    0 The default action for the object.
    –1 Activates the object for editing. If the application that created the object supports in-place activation, the object is activated within the OLE container control.
    –2 Opens the object in a separate application window. If the application that created the object supports in-place activation, the object is activated in its own window.
    –3 For embedded objects, hides the application that created the object.
    –4 If the object supports in-place activation, activates the object for in-place activation and shows any user interface tools. If the object doesn't support in-place activation, the object doesn't activate, and an error occurs.
    –5 If the user moves the focus to the OLE container control, creates a window for the object and prepares the object to be edited. An error occurs if the object doesn't support activation on a single mouse click.
    –6 Used when the object is activated for editing to discard all record of changes that the object's application can undo.

Remarks

If you set the AutoActivate property to 2 (DoubleClick), the OLE container control automatically activates the current object when the user double-clicks the control.

Tip   Although you can use the name of the verb (edit, open, play, and so on) to specify the verb to use with DoVerb, it is much faster to use the index (0, 1, 2, and so on).

Example

The following example adds an OLE Container control to a form, and uses the OleClass and DocumentFile properties to specify Microsoft Excel as the Automation server and a Microsoft Excel worksheet as the file to edit.

The DocumentFile property specifies a worksheet named Book1.xls in the EXCEL directory on drive C. This example will not work properly if the file and directory specified in the DocumentFile property do not exist; it may be necessary to modify the DocumentFile property to specify an existing directory and worksheet file.

* The DoVerb method is used to activate the worksheet for editing.

*frmMyForm = CREATEOBJECT('form')  && Create a form
*frmMyForm.Closable = .F.  && Disable the Control menu box

frmMyForm.AddObject('cmdCommand1','cmdMyCmdBtn')  && Add Command button
frmMyForm.AddObject("oleObject","oleExcelObject")  && Add OLE object

frmMyForm.cmdCommand1.Visible=.T.  && Display the "Quit" Command button

frmMyForm.oleObject.Visible=.T.  && Display the OLE control
frmMyForm.oleObject.Height = 50  && OLE control height

frmMyForm.Show  && Display the form

frmMyForm.oleObject.DoVerb(-1)  && -1 for Edit

READ EVENTS  && Start event processing

DEFINE CLASS oleExcelObject as OLEControl
   OleClass ="Excel.Sheet"  && Server name
   DocumentFile = "C:\EXCEL\BOOK1.XLS"  && This file must exist 
ENDDEFINE

DEFINE CLASS cmdMyCmdBtn AS CommandButton  && Create Command button
   Caption = '\<Quit'  && Caption on the Command button
   Cancel = .T.  && Default Cancel Command button (Esc)
   Left = 125  && Command button column
   Top = 210  && Command button row
   Height = 25  && Command button height

   PROCEDURE Click
      CLEAR EVENTS  && Stop event processing, close form
ENDDEFINE

See Also

OLE Bound Control | OLE Container Control

Applies To: OLE Bound Control | OLE Container Control