Consulting

Results 1 to 10 of 10

Thread: Solved: Calling Userform from Another Workbook

  1. #1

    Solved: Calling Userform from Another Workbook

    Hi,
    I have a userform in workbookA and I want to use workbookB to open workbookA and call the userform and i don't want to use the open event. Is there a way to do that?
    Thanks

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    huh?
    Sorry SherryO, I've been looking at the title for a while and I see no one is replying to your post so I guess I will ask the obvious question, why?

    If you wish to use the same userform in WorkbookB you can export it from A and import it into B. If you want to run macro's from a using that userform from B then you will have to open it.....right?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sherry,

    This is how I have always done it.

    You can't directly open the form from another project (file). What you could do is to create a Public Sub in the project containing the form, and then call that procedure from the other project using Application.Run.

    So in the project with the form, say workbook myFormBook, add


    Public Sub ShowForm()
    UserForm1.Show
    End Sub


    Then, you can call this with Application.Run from the other project with


    Application.Run "'myFormBook.xls'!ShowForm"

  4. #4
    Thank you that is exactly what I am trying to do. I'm new to the whole userform thing, I'm trying. I'm having a problem being able to reference the different projects. It tells me that there is a conflict between them. I think if I could get that fixed your above solution would work. How do I fix the conflict?
    Thank you sooo much.

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Can you post your workbooks so that we can take a look, and detail the steps that you take when using them?

  6. #6
    Thanks for taking the time. I'm just getting started on this project, so please be kind to my ineptitude:> I began it yesterday and I knew I wanted to use UserForms because I wanted to learn how to use them, so I realize that there are actually simplier ways to do the same thing, but I would very much like to stick with the UserForms.
    Thanks again.

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I'm not getting the conflict problem, I stall here on this code

    Call UserForm1_Initialize

    as it is being called from Userform2, a no-no.

    Did you create a new project, or access an exiusting?

  8. #8
    All of it is new. I obvioulsly am new to the userforms. Thanks for your patience!!

    Because you didn't get the conflict, does that mean it's in Personal.xls?

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I have no idea. What steps did you take, and at what point did the error occur.

  10. #10
    Sorry for the delayed response. I didn't see an email with your last response. The error occurs when i try to reference one project to another. I have no idea why. I ended up putting my userform initialize in the workbook open event, so I don't have to call it from the other workbook, so I'm going to mark this as solved, but that error is still bothering me. thanks again for your help.
    sherrryO

Posting Permissions

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