Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks but trying
Set xlApp = GetObject("Book2").Application .... does not work on multiple instances. Tested on windows 7 and excel 2003. "Cannot create activex component" I've checked and checked and checked it, but it is unable to see the opened excel. More details: if the filename is "my book.xls" and is in "c:\here\", I try to open it as: Set xlApp = GetObject("my book").Application Am I missing something ? I cannot include the path as it changes very often... Thanks in advance, Roger On Tuesday, July 22, 2008 6:41 PM ewhit wrote: From within VB.Net, if I want to access an instance of Excel that is already running, I'd use something like. dim Exc as Excel.Application Exc = GetObject(, "Excel.Application") However, suppose I have more than one instance of Excel open. Is there a way to cycle through each open instance, and to pick a specific one to open? -- Ed On Tuesday, July 22, 2008 10:49 PM Doug Glancy wrote: Ed, Check out this page: http://support.microsoft.com/kb/288902 Here's the relevant part: You can attach to a specific instance if you know the name of an open document in that instance. For example, if an instance of Excel is running with an open workbook named Book2, the following code attaches successfully to that instance even if it is not the earliest instance that was launched: Set xlApp = GetObject("Book2").Application Depending on what you're doing you might consider using CreateObject instead and opening the file you are interested in. I think that's generally considered a safer practice. hth, Doug "Ed White" wrote in message ... On Wednesday, July 23, 2008 8:35 AM Peter T wrote: As already suggested, where the filename is known use GetObject to reference the workbook then attach to the parent application. For situations where there is no known loaded wb, Jialiang Ge appears to have demonstrated how to find multiple instances with .net For VBA, I have two methods, briefly: The first enumerates Excel windows, then workbook windows to find the file name of a loaded wb. Having got that try GetObject parent. If that fails, eg no loaded workbooks at all or some other reason, use DDE (from a helper app) to add a new dummy hidden wb and try again. The other way is finding in the ROT (clever stuff, not mine!) There are dis/advantages with each. Via the ROT is faster but can't get be sure to get all instances, eg no loaded wb as can with DDE (usually!). If anyone is interested I have a demo that implements both methods. Having got the ref's the withevents xlApp classes can track and record changes to cells in all wb's in all instances, and one or two other things. Regards, Peter T pmbthornton gmail com "Ed White" wrote in message ... already open? On Thursday, January 21, 2010 1:26 PM Obaid Ullah wrote: Can you share code that enumerates multiple Excel windows. Submitted via EggHeadCafe - Software Developer Portal of Choice Using ASP.NET Session with Silverlight and WCF Services http://www.eggheadcafe.com/tutorials...-services.aspx |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
GetObject when more than 1 Excel is running | Excel Programming | |||
Getting objects other than 'Excel.Application using GetObject() | Excel Programming | |||
Using Excel templates with GetObject/CreateObject | Excel Programming | |||
Controlling Reflection1 from Excel using getObject | Excel Programming | |||
Excel Getobject error | Excel Programming |