Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Slow to Open, Small Workbook <2MB, HTML Paste, VBA procedures Fred Excel Discussion (Misc queries) 0 February 5th 10 09:20 PM
Call SQL Server Stored Procedures with parameters, KCSL Excel Programming 3 July 26th 06 05:05 PM
add-in procedures called from active workbook events doco[_2_] Excel Programming 2 April 25th 06 08:14 AM
two procedures in the same sheet one a workbook even procedure R.VENKATARAMAN Excel Programming 2 September 8th 04 10:46 AM
Passing ARGUMENTS between event procedures of a USERFORM jason Excel Programming 8 November 10th 03 07:36 PM


All times are GMT +1. The time now is 01:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"