+ Reply to Thread
Results 1 to 5 of 5

VBA code to open a user form if the user form is located in an addin?

  1. #1
    Registered User
    Join Date
    08-28-2019
    Location
    london
    MS-Off Ver
    10
    Posts
    2

    VBA code to open a user form if the user form is located in an addin?

    New to VBA here. As I understand it from what I've read elsewhere, there are two methods to do this:

    1. Add the addin project in Tools > references and then open the form with UserForm1.show

    2. Use Application.Run "FileName.xlam!Sub"

    I can't get either of these to work! Any help greatly appreciated.

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: VBA code to open a user form if the user form is located in an addin?

    Your syntax looks incorrect and is missing a set of single quotes. Try this.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-28-2019
    Location
    london
    MS-Off Ver
    10
    Posts
    2

    Re: VBA code to open a user form if the user form is located in an addin?

    Thanks very much for your reply! I've changed it to the following:

    Application.Run "'EC_List_Search.xlam'!UserForm_Initialize"

    and still get the error: "Application defined or object-defined error"

    I read something about putting code in a module of the workbook that you're trying to open it from the link below but also can't get this working:

    mrexcel.com/board/threads/display-userform-that-exists-in-add-in.47977/

    Is it that I need to declare it as an object in the workbook I'm trying to open it from?

  4. #4
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: VBA code to open a user form if the user form is located in an addin?

    It may be time for you to share some code as it could be something in your actual code causing the error. My guess is that you are trying to load the form in the script being used in your non-addin file.
    In your addin file, you should have both

    1. Your userform
    2. A script to call the userform in a standard module.

    Please Login or Register  to view this content.
    And you can call and load your userform from another file by calling that script.

    Please Login or Register  to view this content.

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: VBA code to open a user form if the user form is located in an addin?

    You can't run a userform event code like that. You need to add a routine to the add-in that either just shows the form, or loads it and returns a reference to it as its result.
    Rory

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Upload inputs from a User Form repeatedly until the user clicks the red X on the Form
    By TheJimmyMcGill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2019, 05:46 PM
  2. Populate text boxes on user form, from combo box on same user form
    By Richardswaim in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 07-03-2016, 09:35 AM
  3. [SOLVED] User Form to execute search and return all values to the user form for editing
    By allwrighty in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2013, 10:40 PM
  4. [SOLVED] Excel vba user form- open directly to user form not worksheet
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 04-24-2013, 05:07 PM
  5. [SOLVED] Excel user form- If/Then statement outcome to show on user form
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-18-2013, 09:16 AM
  6. Code to pop-up User Form on workbook open
    By Mile029 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-28-2012, 04:02 PM

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