Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
my excel settings changed and i have only 1 instance running. Melissa Setting up and Configuration of Excel 1 March 28th 10 04:30 AM
Excel - New Instance JMay Excel Discussion (Misc queries) 4 November 28th 09 04:55 PM
Running Two Instance of Excel 2003 Simultaneously - Advice Please Dermot Excel Discussion (Misc queries) 11 February 20th 08 12:04 AM
opening and running macros in an Excel file in a new instance of Excel Malone[_2_] Excel Programming 0 September 30th 03 01:58 AM
Second instance of Excel Dom[_2_] Excel Programming 1 August 25th 03 05:37 PM


All times are GMT +1. The time now is 05:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ╘2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"