Introduction of MSScriptControl. ScriptControl Component Properties, Methods and Events


MSScriptControl. ScriptControl Component Instance Object Properties

Property name type Remarks
AllowUI BOOL Check whether user interface elements are allowed to run. If it is False, interface elements such as message boxes are not visible.
CodeObject Object The script is exposed to the object that the host calls. Read only.
Modules Modules The component library module provided by the host to the script. Read only. (COM components usually provide users with a set of objects that can be left for their secondary development in the form of object collection, each collection is a Modules)
Language String Set or get the language interpreted by the script engine, such as VBScript, JScript.
Name String The name of the script engine. Read only.
Procedures Procedures Returns the set of processes defined in the module
SitehWnd HWND Display the parent window handle of the UI in the script
State Enum Sets or returns the state of the control. If 0, the control only executes statements but does not forward events, and 1 is the object forwarding event accepted by the added control.
Timeout Long Control execution script timeout value, -1 means no timeout
UseSafeSubset BOOL Set or return whether the host program cares about security. The security level of the host program can be set from this property
Error Error Error object, which returns an error object when an error occurs

MSScriptControl. ScriptControl Component Instance Method Name

Method name parameter function
AddCode Code As String Add scripts to the script engine to execute
AddObject Name As String, Object As Object, [AddMembers As Boolean = False] Add an object to the script engine so that the method provided by the object can be used in the script.
Eval Expression As String Expression evaluation
ExecuteStatement Statement As String Explain and execute script statements
Reset   Discard all objects and code and set the State property to 0.
Run ProcedureName As String, ParamArray Parameters() As Variant Running a specified process

MSScriptControl. ScriptControl Component Instance Event Name

Event name function
Error Fire the event when an error occurs
TimeOut Execution process timeout occurs

Use of MSScriptControl.ScriptControl

1. Adding Script Control to Program
2. Define an instance of ScriptControl
3. Call AddCode and other methods to add scripts to the script engine to execute.
4. Call Run to execute script functions to be executed.