Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Call UserForm procedures from another workbook
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Call UserForm procedures from another workbook
I get compile errors. Dim€¦UserForm1 errors to €śUser-defined type not defined€ť
but I guess the 1 is the problem. But removing it I get €śInvalid use of New keyword€ť in the Loadform procedure instead! Please observe that the UserForm is already loaded but hidden when working in the other workbook. Excel seems to have a problem pasting data to cells linked to the UserForm (textboxes), very often it starts calculating endlessly. (Ctrl-Alt-Del is the only way out). I had an idea to reduce the workload after the paste operation by reducing the number of steps getting back and show the UserForm again. Regards Mats "Bob Phillips" wrote: 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Slow to Open, Small Workbook <2MB, HTML Paste, VBA procedures | Excel Discussion (Misc queries) | |||
Call SQL Server Stored Procedures with parameters, | Excel Programming | |||
add-in procedures called from active workbook events | Excel Programming | |||
two procedures in the same sheet one a workbook even procedure | Excel Programming | |||
Passing ARGUMENTS between event procedures of a USERFORM | Excel Programming |