PDA

View Full Version : Solved: Calling Userform from Another Workbook



SherryO
10-18-2006, 01:06 PM
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

lucas
10-18-2006, 02:28 PM
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?

Bob Phillips
10-18-2006, 03:16 PM
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"

SherryO
10-19-2006, 05:50 AM
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.

Bob Phillips
10-19-2006, 05:54 AM
Can you post your workbooks so that we can take a look, and detail the steps that you take when using them?

SherryO
10-19-2006, 06:07 AM
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.

Bob Phillips
10-19-2006, 11:17 AM
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?

SherryO
10-19-2006, 11:46 AM
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?

Bob Phillips
10-19-2006, 01:06 PM
I have no idea. What steps did you take, and at what point did the error occur.

SherryO
10-20-2006, 11:03 AM
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