Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine if instance of Excel is running
I am trying to use excel from Visual basic.
I am having the probelm when a second instance of the VB is opened. Th sheet will hidden behind sme application and I am able to see only th tool bars which are on top. I have closed all the workbooks befor opening another. Is there any method to know if a excel instance is running. Please hel with a solution. Thanks in Advance Anan -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine if instance of Excel is running
"anandmr" wrote in message ... I am trying to use excel from Visual basic. I am having the probelm when a second instance of the VB is opened. The sheet will hidden behind sme application and I am able to see only the tool bars which are on top. I have closed all the workbooks before opening another. Is there any method to know if a excel instance is running. Please help with a solution. The easiest way is to attempt to use automation to connect to an existing instance and only create a new instance if that fails. Its is possible to use the win32 API's to get a list of running processes but its complex. The following function will attach to a current instance or create a new one Public Function open_excel (xlapp as Excel.Application) as Boolean ' First lets find out if Excel is already running On Error GoTo excel_start: Set xlapp = GetObject(, "Excel.Application") ' Make sure Excel is visible xlapp.Application.Visible = True open_excel = True Exit Function ' Excel not running error handler excel_start: On Error GoTo No_excel_err: Set xlapp = New excel.Application open_excel = True xlapp.Application.UserControl = True = "Starting Excel" Splash_scrn.Show Exit Function ' Excel not found error handler No_excel_err: msg = "Fatal Error - Unable to start Excel " & Chr$(10) & _ "Please check your installation" MsgBox msg, vbCritical open_excel = False Exit Function End Function Keith |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine if instance of Excel is running
Hi, Keith.
Is it possible to run my own Excel instance, so that no one can bind to my instance? Yury. "Keith Willshaw" сообщил/сообщила в новостях следующее: ... The easiest way is to attempt to use automation to connect to an existing instance and only create a new instance if that fails. Its is possible to use the win32 API's to get a list of running processes but its complex. The following function will attach to a current instance or create a new one Public Function open_excel (xlapp as Excel.Application) as Boolean ' First lets find out if Excel is already running On Error GoTo excel_start: Set xlapp = GetObject(, "Excel.Application") ' Make sure Excel is visible xlapp.Application.Visible = True open_excel = True Exit Function ' Excel not running error handler excel_start: On Error GoTo No_excel_err: Set xlapp = New excel.Application open_excel = True xlapp.Application.UserControl = True = "Starting Excel" Splash_scrn.Show Exit Function ' Excel not found error handler No_excel_err: msg = "Fatal Error - Unable to start Excel " & Chr$(10) & _ "Please check your installation" MsgBox msg, vbCritical open_excel = False Exit Function End Function Keith |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine if instance of Excel is running
"Yury Lobanov" wrote in message ... Hi, Keith. Is it possible to run my own Excel instance, so that no one can bind to my instance? Yury. You can certainly instantiate a separate Excel invocation but as far as I know there's no way to prevent another app connecting to it. Keith |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine if instance of Excel is running
"Application.IgnoreRemoteRequests = True" will keep your instance private.
Be sure to set it back to False before you shut down that instance. Regards, Vic Eldridge Is it possible to run my own Excel instance, so that no one can bind to my instance? Yury. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine if instance of Excel is running
Hi Vic,
"Application.IgnoreRemoteRequests = True" will keep your instance private. Be sure to set it back to False before you shut down that instance. FWIW, that will only stop DDE requests (such as when launching a file from Explorer), but won't stop OLE requests (such as when double-clicking an Excel file embedded in a Word document or using any other application that uses GetObject() to find a running instance of Excel to use. Regards Stephen Bullen Microsoft MVP - Excel www.BMSLtd.co.uk |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine if instance of Excel is running
FWIW, that will only stop DDE requests (such as when launching a file from Explorer), but won't stop OLE requests (such as when double-clicking an Excel file embedded in a Word document or using any other application that uses GetObject() to find a running instance of Excel to use. Oh no, foiled again! Perhaps if Yury is keen he can look into the RevokeActiveObject API which will remove an object's entry in the Running Object Table, (which is where GetObject() goes to do it's work). I wish him the very best of luck! Here's a start... http://support.microsoft.com/default...b;en-us;155690 Regards, Vic Eldridge |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to determine if instance of Excel is running
Thanks Vic, now i know there is a way, i suppose i'll try later...
"Vic Eldridge" ???????/???????? ? ???????? ?????????: m... FWIW, that will only stop DDE requests (such as when launching a file from Explorer), but won't stop OLE requests (such as when double-clicking an Excel file embedded in a Word document or using any other application that uses GetObject() to find a running instance of Excel to use. Oh no, foiled again! Perhaps if Yury is keen he can look into the RevokeActiveObject API which will remove an object's entry in the Running Object Table, (which is where GetObject() goes to do it's work). I wish him the very best of luck! Here's a start... http://support.microsoft.com/default...b;en-us;155690 Regards, Vic Eldridge |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
my excel settings changed and i have only 1 instance running. | Setting up and Configuration of Excel | |||
Excel - New Instance | Excel Discussion (Misc queries) | |||
Running Two Instance of Excel 2003 Simultaneously - Advice Please | Excel Discussion (Misc queries) | |||
opening and running macros in an Excel file in a new instance of Excel | Excel Programming | |||
Second instance of Excel | Excel Programming |