Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 15th, 2004, 06:46 PM
Registered User
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Possible to run macro from another workbook?

Is is possible to run a macro from another workbook?

Here's the situation:
I have a user form with a button that opens a new workbook, the dimensions of which are about half the screen size. The form covers the new workbook (even if set to modeless). So, I reduce the form's height when the new workbook is opened allowing the new workbook to be visible. When the new workbook is closed, I want the form to return to its original height. But, as far as I can see, the code to do that has to be in the original workbook in which the form resides.

How can I get the form to return to its original size when the other workbook is closed?
 
Old October 5th, 2004, 04:23 AM
Authorized User
 
Join Date: Aug 2004
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have no experience of modeless forms, but, in the absence of other replies :-

1. The answer to question 1 is Yes. Use code like :-
Application.Run("BOOK1.XLS!MyMacroName")
2. You probably had the code already, but you can reset the height of a form with someting like :- UserForm1.Height = 250
3. If the workbook is closed with code you can oviously reset there. Otherwise, while searching the web for information about Class Modules, I saw one which can be set up to trap events at Application level - eg WorkBook_Close etc. which would seem appropriate here. Sorry, I do not remember where.

Hope this helps.



-----------------------
Regards BrianB
Most problems occur from starting at the wrong place.
Use a cup of coffee to make Windows run faster.
It is easy until you know how.
 
Old September 26th, 2009, 08:00 PM
Registered User
 
Join Date: Sep 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This code worked GREAT! Thank you





Similar Threads
Thread Thread Starter Forum Replies Last Post
on opening workbook, how to disable macro ? jjk2 Beginning VB 6 1 January 7th, 2008 05:05 AM
Generate A Workbook With Macro Included robnot Excel VBA 1 February 16th, 2007 07:08 PM
How to run events independently on each workbook ? yaushern Excel VBA 4 December 18th, 2006 06:12 AM
personal macro workbook helmekki Excel VBA 0 May 31st, 2004 03:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.