Executes a method of an object, or sets or returns a property of an object.
CallByName(object, procname, calltype,[args()])
The CallByName function syntax has these named arguments:
Required; Variant (Object). The name of the object on which the function will be executed.
Required; Variant (String). A string expression containing the name of a property or method of the object.
Required; Constant. A constant of type vbCallType representing the type of procedure being called.
Optional: Variant (Array).
The CallByName function is used to get or set a property, or invoke a method at run time using a string name.
In the following example, the first line uses CallByName to set the MousePointer property of a text box, the second line gets the value of the MousePointer property, and the third line invokes the Move method to move the text box:
This example uses the CallByName function to invoke the Move method of a Command button.
The example also uses a form (Form1) with a button (Command1), and a label (Label1). When the form is loaded, the Caption property of the label is set to "Move", the name of the method to invoke. When you click the button, the CallByName function invokes the method to change the location of the button.