Convert Excel Spreadsheet controls to VB form


  • I am converting an Excel spreadsheet with VBA macros to VB.  I have been able to export all of the VBA macros (.frm, .cls, .bas), but cannot figure out how to export the controls embedded on an Excel spreadsheet to a VB form (e.g. =EMBED("Forms.CommandButton.1","").  I have buttons, check boxes, list boxes, etc. embedded in an Excel spreadsheet.  In the macro editor, I can see the controls in the object browser window. For example:

    cmdPrvFirst As CommandButton
        Member of VBAProject.Sheet1

    Copy/paste does not work.  How can I do this?  I hate to have to create the VB forms from scratch.

    Saturday, April 03, 2010 7:40 PM


  • Dave,

    I am not sure there is an easy way to do this.

    but what i suggest to maybe make it easier and not have to build everything manually is to use code to your advantage and write the designer code in your vba project then transfer it over to

    In your project, solution explorer, click the show all files button at the top.  then open the designer.vb file for one of your forms.  you will see the designer code that creates your controls on the form.

    with a single button on a form it will look something like this

    Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button1.Location = New System.Drawing.Point(0, 0)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(75, 23)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Button1"
        Me.Button1.UseVisualStyleBackColor = True
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Name = "Form1"
        Me.Text = "Form1"
      End Sub
      Friend WithEvents Button1 As System.Windows.Forms.Button

    look closely at all the button code, you can write this code yourself in the vba project, using vba code.  just get the properties of each control in your vba project and have it write code to match.

    Now, this might end up being more work than just doing the forms manually in project but if you have a lot of controls this can be faster.  you can also copy and paste the designer code, and change the names, locations, etc.

     if you do some searching you might should be able to find vba code to get all properties of a control.

    this is probably not what you are looking for but might help.  hope it does


    Upload Projects to share or get help on and post the generated links here in the forum
    • Marked as answer by Jeff Shan Friday, April 09, 2010 5:48 AM
    • Marked as answer by Jeff Shan Friday, April 09, 2010 5:48 AM
    Saturday, April 03, 2010 8:39 PM