Results 1 to 19 of 19

Trouble creating a UserForm programmatically

Threaded View

  1. #1
    Registered User
    Join Date
    08-14-2014
    Location
    Cedar Falls, Iowa
    MS-Off Ver
    2013
    Posts
    11

    Trouble creating a UserForm programmatically

    I am having issues with writing code that creates a UserForm on Excel 2013. I have searched Microsoft help sites as well as many other sites for solutions, and I have figured out that I don't have a problem with the coding, but it is a problem that I have no idea how to solve.

    I found a MS help website that walked me through how to create a UserForm using VBA code. It said to first click tools > references > check MS VBA Extensibility. I then copy and pasted their sample code, but it gave me the error: Run-time error '1004': Application-defined or object-defined error. I then went back to references and saw that MS VBA Extensibility's location is given as C:\Program Files (x86)\Common Files\Microsoft Shared\VBA. I went into the MS Shared folder, but didn't find VBA, so I copied it to my computer from another computer in my office. That did not fix the problem. I am wondering if I may be missing files? The only folder inside VBA is VBA6 which contains only VBE6EXT.OLB. I have tried running code that claims to create a UserForm, but I keep getting the same error. Here is an example of the code I have tried using.

    Sub Add_Form1()

    ' Declare a variable to hold the UserForm.
    Dim x As Object

    ' Create a new UserForm. You can use this new VBComponent object
    ' to manipulate the User Form.
    Set x = Application.VBE.ActiveVBProject.VBComponents.Add _
    (vbext_ct_MSForm)

    End Sub

    My error is on the line Set x = Application.VBE.....
    When I manually type in the code, VBA recognizes everything I am typing in (it will give me autofill options), so I am stumped as to why this code won't work for me.
    Last edited by Mitch319; 08-18-2014 at 11:56 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to programmatically add items to a userform combo box
    By dec789 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2012, 10:59 PM
  2. Creating values for list programmatically.
    By ballack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2007, 04:30 AM
  3. add button to UserForm programmatically
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-01-2006, 08:10 AM
  4. [SOLVED] Create UserForm programmatically
    By Ber in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-11-2005, 07:05 AM
  5. [SOLVED] Programmatically creating a map from data in Excel
    By David Brockus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-08-2005, 05:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1