PC Review


Reply
Thread Tools Rate Thread

Calling Form Routine from Another Workbook

 
 
Denis
Guest
Posts: n/a
 
      30th Oct 2008
You can call a routine in another workbook by doing:
Application.Run "SomeBook.xls!SomeRoutine"

Since you can call a routine in a form by:
Call SomForm.FormRoutine

I was hoping that you could call a form routine from another workbook
by doing:
Application.Run "SomeBook.xls!SomeForm.FormRoutine"
but this doesn't work.

Is there a way to do this?

On a related note, is there a way to unload a form from another
workbook. My understanding is that calling a routine in a form will
automatically load it (if it isn't already loaded) but there are times
when you would want to unload a form to guarantee you are starting
fresh.

Denis
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      30th Oct 2008
1.
Application.Run "SomeBook.xls!SomeForm.SomeRoutine"

Put code in SomeRoutine to run (ie load and show) the form (in same project
as SomeRoutine)

2.
Yes you are right, as soon as you reference a userform it will load into
memory and stay there until explicitly unloaded (or the wb is closed)

To unload one or all forms in a project -

Dim i as long

For i = 1 to Userforms.count To 1 Step -1
' If Userforms(i - 1).name = "myFormName" Then '' only unload this form
Unload Userforms(i - 1)
' End If
Next

uncomment "If..." & "End If" to only unload a particular form, if loaded


Regards,
Peter T


"Denis" <(E-Mail Removed)> wrote in message
news:3c07c7f1-3593-4b79-bab4-(E-Mail Removed)...
> You can call a routine in another workbook by doing:
> Application.Run "SomeBook.xls!SomeRoutine"
>
> Since you can call a routine in a form by:
> Call SomForm.FormRoutine
>
> I was hoping that you could call a form routine from another workbook
> by doing:
> Application.Run "SomeBook.xls!SomeForm.FormRoutine"
> but this doesn't work.
>
> Is there a way to do this?
>
> On a related note, is there a way to unload a form from another
> workbook. My understanding is that calling a routine in a form will
> automatically load it (if it isn't already loaded) but there are times
> when you would want to unload a form to guarantee you are starting
> fresh.
>
> Denis



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a VBA sub routine Howard Microsoft Excel Programming 5 22nd Dec 2008 12:32 AM
name of calling routine =?Utf-8?B?U21hbGx3ZWVk?= Microsoft Excel Programming 1 2nd Oct 2007 05:45 PM
calling sub-routine Lodewijk Microsoft Access Form Coding 2 30th Mar 2005 09:21 PM
calling sub-routine Lodewijk Microsoft Access Forms 2 30th Mar 2005 09:21 PM
Calling a form from form routine =?Utf-8?B?Sk1vcnJlbGw=?= Microsoft Access 0 9th Nov 2004 07:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:16 PM.