How about an example on how to use scripting capabilities in your application, if the script control is available, without setting any references? ‘Attempt to get the type for the script control. Dim ScType As System.Type = System.Type.GetTypeFromProgID( _ “MSScriptControl.ScriptControl”) ‘If the prog ID is missing, Null is returned (Nothing in Visual Basic). If ScType Is Nothing Then MessageBox.Show(“The Script Control is not available.”) Else Dim Sc As Object = System.Activator.CreateInstance(ScType) ‘All is well. Configure the script control: Set language. Dim LanguageParameterValue() As Object = {“VBScript”} ScType.InvokeMember(“Language”, Reflection.BindingFlags.SetProperty, Nothing, Sc, _ LanguageParameterValue, Nothing) ‘Allow UI operation (such as MsgBox). Dim AllowUIParameterValue() As Object = {True} ScType.InvokeMember(“AllowUI”, Reflection.BindingFlags.SetProperty, Nothing, Sc, _ AllowUIParameterValue, Nothing) ‘Finally, set timeout to [forever]. Dim TimeoutParameterValue() As[…]

Once you have an object, you can dynamically decide what method to call, or property to use, by calling the InvokeMember function of the object’s type. In this example, I call the ShowDialog method of the object. Note that object members (non static) must have target instance, in my case X. Dim X As New Form1() Dim T As Type = X.GetType() T.InvokeMember(“ShowDialog”, Reflection.BindingFlags.InvokeMethod, Nothing, X, Nothing) How you do things with COM objects that you don’t have a reference to, depends on if you are using Visual Basic in strict mode or not. If option strict is off, this code will actually run: Dim X As Object = Microsoft.VisualBasic.Interaction.CreateObject(“ADODB.Connection”) X.ConnectionString = “Hej” If option strict is on, you will[…]