Microsoft KB Archive/185461

= PRB: UseSafeSubset Allows Non-safe Objects to Be Called =

Article ID: 185461

Article Last Modified on 6/30/2004

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
 * Microsoft Visual Basic for Applications 5.0

-



This article was previously published under Q185461



SYMPTOMS
When using the Microsoft Script control with the UseSafeSubset property set to TRUE, script code is still able to instantiate objects that have not been marked safe for scripting.



CAUSE
The program is using version 1.0 of the Microsoft Script Control.

NOTE: An alternate cause, not addressed elsewhere in this article is that your VBA application is resetting the UseSafeSubset property to FALSE.



RESOLUTION
To correct this problem, upgrade to version 6.0 of the Microsoft Script Control. For additional information, please see the following article in the Microsoft Knowledge Base:

184739 INFO: Where to Obtain the Script Control



STATUS
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures.

Steps to Reproduce Behavior
  In Visual Basic create a new project and add the following component: Microsoft Script Control 1.0  Add the Script control (ScriptControl1), a text box (Text1), and a command button (Command1) to a form. In Visual Basic, set the MultiLine property of the text box to TRUE. For ease of use change the size of Text1 so that it will accommodate 5 lines of 60 characters.  Add the following code: Private Sub Command1_Click On Error Resume Next With ScriptControl1 .UseSafeSubset = True .Language = "VBScript" .AllowUI = True .AddCode Text1.Text .Run "Test" End With End Sub  Run the form and open the Debug window.  Type the following script into the text box. If you do not have Microsoft Excel, use a different server application. Sub Test Dim X       Set X = CreateObject("Excel.Application") X.Visible = True    ' this line is Excel-specific MsgBox "Pausing for effect...." Set X = Nothing End Sub </li> Click the command button. Microsoft Excel is displayed.</li> Click OK on the message box and Excel will close.</li> Install version 6.0 of the control and re-run. You will get a trappable error indicating that the object is not marked safe for scripting:

Run-time error '429':

ActiveX component can't create object 'createobject'

</li></ol>

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Malcolm Stewart, Microsoft Corporation

Additional query words: kbAutomation kbScript kbVBp kbVBp500 kbVBp400 kbVBA5 kbVBp600 kbdse kbDSupport

Keywords: kbscript kbprb KB185461

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.