Microsoft KB Archive/172244

= BUG: VBComponents Add method cannot add a Form =

Article ID: 172244

Article Last Modified on 8/19/2004

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Control Creation Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition

-



This article was previously published under Q172244



SYMPTOMS
When attempting to add a Form to a Visual Basic 5.0 project through the IDTExtensibility model with VBComponents' Add method and passing vbext_ct_MSForm, you get Run-time error '-2147467259 (800004005)':

"System Error &h80004005(-2147467259). Unspecified error"



CAUSE
Visual Basic 5.0 does not support UserForms designers, enum member vbext_ct_MSForm is not valid.



RESOLUTION
Use VBComponents' AddFromTemplate method. See the MORE INFORMATION Section of this article.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section. Microsoft is researching this bug and will post more information in this article when the information becomes available.



Steps to reproduce the problem
 Start a New AddIn Project in Visual Basic 5.0.  Add the following line to the Private Sub OKButton_Click in frmAddIn: VBInstance.VBProjects(1).VBComponents.Add (vbext_ct_MSForm)  Type "ADDTOINI" in the Immediate (debug) window and press the ENTER key. Press the F5 key to run the project. Start another instance of Visual Basic with a new standard EXE project*.</li> Under Add-Ins menu, select Add-In Manager, and then select My AddIn from the list.</li> Under Add-Ins menu, select My AddIn item.</li> Click OK on the Add-In Form. You will get:

Run-time error '-2147467259 (800004005)': System Error &h80004005(-2147467259). Unspecified error.

</li> Add a new form to the add-in project and save it in the 'Template' folder under Visual Basic folder as Form1.frm (for example, 'C:\Program Files\DevStudio\VB\Template', and then remove the form from the project.</li>  Change the code:      VBInstance.VBProjects(1).VBComponents.Add (vbext_ct_MSForm) in step 6 to:       VBInstance.VBProjects(1).VBComponents.AddFromTemplate _      ("C:\Program Files\DevStudio\VB\Template\Form1.frm")                        </li> Repeat steps 3 through 8. This time a form should be added to your project each time you click OK.</li></ol>


 * If your project does not have a form, you will get 'Run-time error #9, subscript out of range.'

Keywords: kbbug KB172244

-

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

© Microsoft Corporation. All rights reserved.