View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Prevent multiple instances of Excel from starting

If your third party stand alone app is doing it's own thing with it's own
instance of Excel, I don't think it would matter how many instances exist.

A guess, and a wild guess, perhaps the problem is the opposite of what you
think, namely not enough instances, ie user inadvertently using your app's
instance. Your app starts a new (invisible) instance for it's own purposes,
if then user opens an xls via explorer this may open up in your app's
instance and also make it visible. But later user closes that instance your
app is lost!.

You can demonstrate this for yourself -

Uncheck "Ignore other applications" in Tools / General.
Close all instances of Excel.
In Word, insert a new module (Alt-Fll, Alt-i, m)

Dim oXL As Object
Dim oWB As Object
Dim bRequests As Boolean

Sub StartXL()

Set oXL = CreateObject("Excel.Application")
Set oWB = oXL.Workbooks.Add
bRequests = oXL.IgnoreRemoteRequests

'oXL.IgnoreRemoteRequests = True

oWB.Worksheets(1).Range("A1") = "Started by Word"
MsgBox oWB.Name
' oXL.Visible = True

End Sub

Sub CloseXL()
Dim wbCount As Long
On Error Resume Next
oWB.Close False
Set oWB = Nothing
If Err.Number Then
MsgBox "oWB does not exist"
Err.Clear
End If
wbCount = oXL.Workbooks.Count
If wbCount Then
MsgBox "Someone's got a WB open in my XL !"
oXL.Visible = True
Exit Sub
End If

oXL.IgnoreRemoteRequests = bRequests
oXL.Quit

If Err.Number Then
MsgBox "oXL does not exist"
Err.Clear
End If
Set oXL = Nothing

End Sub

Start an invisible XL with StartXL

Now double click an xls file in Explorer to open

It's opened in Word's instance of xl - right?. Close the file you just
opened

Run CloseXL

Repeat but his time also close XL manually after loading some file. Run
CloseXL again.

Repeat again, don't manually close the xls you just open but close via Word

And yet again but this time un-comment the line
'oXL.IgnoreRemoteRequests = True

As I say, all this is entirely a guess as to your problem, and doesn't quite
fit what you say about your app only using Excel to display and input data.

Regards,
Peter T

"Robert Mulroney" '''' wrote in message
...
The 3rd party product is an OLAP-DBMS. We link it to Excel via an add-in

that
was provided by the 3rd party which contains a number of worksheet formula
specifying data-slices. I also tend to use it as a COM object in VBA

because
I find the formula interface a bit cumbersome.

The addin starts a background task that controls all the data access
calculations. So presumably it's using the DBMS as COM object too. Excel

is
only used to display and input data, few data calulations just UI. The

task
is more or less an executable file, an application that can be started
without excel.

A lot of the addins functions are based on worksheet ranges for input and
output of the OLAP slices. For some reason these formula don't like to

work
when multiple instances of Excel are open together. It's almost as if

there's
a programming error where someone hasn't properly referenced the a range
properly.

I don't have access to get in an look at what's going-on in the addin.
They're very protective of their little chunk of code. I'm not sure why,

the
whole product is a little bit unstable and has a number of, well I'll call
them quirks to be polite. I seem to find myself constantly looking for

work
arounds like this one.



- Rm