View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Call UserForm procedures from another workbook

You cannot access a class in another workbook, and a userform is just a
special type of class, add-in or not, directly. You have to get at it in a
roundabout way.

In the workbook with the userform create a standard code module procedure
for creating a form object and loading the form

Dim theForm As UserForm1

Sub LoadForm()
Set theForm = New UserForm1
End Sub

and another procedure to call into the form to invoke one of its methods
(make sure that the method is decalred as Public)

Sub CallIntoForm()
theForm.cmdButton_Click
End Sub


Then in the calling workbook, you invoke that routine like so


Application.Run "'The Userform Workbook.xls'!LoadForm"
Application.Run "'The Userform Workbook.xls'!CallIntoForm"


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Mats Samson" wrote in message
...
Is it possible to Run a Userform.Show and call/run a procedure in the
Userform from another active workbook once the form is loaded but hidden.
I'm switching from the Userform to the "data" workbook, selects the data
to
copy and press a button to copy & paste, switching back to the Userform
and
continues to manipulate the data. I can do it with starting a procedure in
a
module in the same workbook as the userform but I'd like to jump directly
back to the Userform.