PDA

View Full Version : How to control which vba Excel program has control on computer



stevespauldi
03-31-2010, 04:57 AM
I have two separate vba Excel programs which interact with each other.

Right now, whichever program I open first (and enable macros) has control on my computer (even when I programmatically activate a window in the other program).

There are times I want vba control to be taken by the other program. How do I control which program has control (vba/macro-wise) on my computer?

Thanks,
Steve

Paul_Hossler
03-31-2010, 08:08 AM
Question: two instances of Excel.exe each with one workbook, OR 2 workbooks open in a single instance of Excel.exe?

Paul

Aussiebear
03-31-2010, 01:08 PM
I'd say from reading the post Paul, that he's talking about the first.

Paul_Hossler
03-31-2010, 06:00 PM
I'd say from reading the post Paul, that he's talking about the first.

Just wanted to understand since activating another workbook is very different from activating another instance of Excel.

We have a guy at work who's (in)famous for have 3 or more Excel instances open with 2 or more workbooks in some of them. He wonders why he has crashes and macro and ribbon disconnects.



I have two separate vba Excel programs which interact with each other.


Steve -- can you use one Excel instance, with 2 macro workbooks?

Paul

SamT
04-01-2010, 07:31 AM
Dim objThatOtherBook As Workbook
If Not Workbooks("Other Book's Name") IsNothing Then 'Book is open
Set objThatOtherBook = Workbooks("Other Book's Name")
Else 'book is not open
Exit Sub
End If

Call objThatOtherBook.MacroName()
' OR
Call objThatOtherBook.ModuleName.MacroName()
'where ModuleName is the name of the module the macro is in

stevespauldi
04-02-2010, 05:17 AM
I have two separate Excel workbooks (both with vba macros).

- Steve