Reusable Automation.. (1 Viewer)

JaedenRuiner

Registered User.
Local time
Today, 04:13
Joined
Jun 22, 2005
Messages
154
I'm having an issue with vba automation, allowing me to control Word, Excel, and Outlook all from one source module. However, the issue is, what happens when the module closes. I need to be able to reactivate my form and interface module without any fuss, but I can seem to do find it.

word1.doc:
set xlApp = New Excel.Application

Now, that creates an instance of Excel, from which i can open and manipulate workbooks, worksheets, etc, and I can automate it from word1.doc.

Now I close word1.doc, so the module is terminated, however, my instance of Excel is still open.

Now I reopen word1.doc -> /????? I can't connect to that original Excel instance.

I mean, what is the point of the Workbooks Collection, when you can latch on to the existing application server from another office app? I mean, in the Excel.Application object there is a method: ActivateMicrosoftApp(), which will activate an instance of a currently running MS app, or will start one if it isn't running yet. Why doesn't Word, Access, PowerPoint, and the like have that exact same functionality, why only Excel?
Not to complain to harshly against microsoft because that would take too long, but can I automate Excel from Word effectively enough so that I can just jump onto the currently running excel application server, instead of having to "create" one all the time?

Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
 

freakazeud

AWF VIP
Local time
Today, 06:13
Joined
Sep 10, 2005
Messages
221
re:

Hi,
I'm not exactly sure what you are doing as your code sample doesn't make sense to me...however I would strongly suggest using late binding with the CreateObject() as well as the GetObject() method. You can read their behavior here. Using late binding will also eliminate the need to include all these different references to the office applications which can cause issues in multi version usage.
HTH
Good luck
 

JaedenRuiner

Registered User.
Local time
Today, 04:13
Joined
Jun 22, 2005
Messages
154
Awesome...perfect. The GetObject worked perfectly. Thanks
 

Users who are viewing this thread

Top Bottom