ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   excel interop: identifying when excel has "initialized" (https://www.excelbanter.com/excel-programming/368586-excel-interop-identifying-when-excel-has-initialized.html)

Peter

excel interop: identifying when excel has "initialized"
 
This is a question about Excel interop. Any insight would be appreciated.

Question:

Is there any way (ie. event, property, hack, etc) to know when Excel has
initialized? I know this is probably not well-defined, but I would define it
as "all addins for the particular Excel process have initialized" since that
is most useful to my situation.

I have looked at a number of the interop capabilities (properties, events,
etc), nothing i have tried works though.

Background:

We are writing a program in .Net 1.1 using C# that targets the Excel 2000
Interop assemblies, but is being tested with Excel 2003 application which has
some 3rd party addins installed.

We have observed:

1) when "new Excel.ApplicationClass()" is used to start a new Excel process,
the addins do not properly initialize.

2) when starting a new Excel process using Process.Start(), the addins
initialize properly if I wait long enough (eg. sleep for 10 seconds to give
them time)

2.1) if I do not wait long enough, race-condition results occur, and the
addins do not initialize. other side effects (multiple excel processes, error
dialogs) also occur depending on situation, number of addins, etc.

2.2) "waiting long enough" is not well-defined since it is unknown the addin
configuration of a given client. also addins can raise dialogs on load which
require user feedback to complete.

Once again, any insight would be appreciated. Thanks.

NickHK

excel interop: identifying when excel has "initialized"
 
Peter,
I can't answer your question for .Net, but from VB6:
Dim XLApp as Excel.Application
Set XLApp=New Excel.Application
XLApp.Workbooks.Add

The last line cannot execute until the Excel instance is up and running.

Excel 2003 (or maybe 2002) has an Application.Ready property that you can
may be check. It is supposed to indicate if Excel can respond. However, if
it cannot respond, I don't know how it is supposed to return the value of
this property. It apparently always returns True, which makes sense as it
would be illogical to return False.

Dim XLApp As Excel.Application

Private Sub Form_Load()
Dim i As Long
Dim InstalledCount As Long

Set XLApp = New Excel.Application

With XLApp
For i = 1 To .AddIns.Count
If .AddIns(i).Installed = True Then
InstalledCount = InstalledCount + 1
End If
Next
MsgBox "There are " & InstalledCount & " addins installed"
.Visible = True
'.Quit
End With

End Sub

So I would assume your problems are thread related and/or the way .Net
instantiates objects compared to VB.

NickHK

"Peter" wrote in message
...
This is a question about Excel interop. Any insight would be appreciated.

Question:

Is there any way (ie. event, property, hack, etc) to know when Excel has
initialized? I know this is probably not well-defined, but I would define

it
as "all addins for the particular Excel process have initialized" since

that
is most useful to my situation.

I have looked at a number of the interop capabilities (properties, events,
etc), nothing i have tried works though.

Background:

We are writing a program in .Net 1.1 using C# that targets the Excel 2000
Interop assemblies, but is being tested with Excel 2003 application which

has
some 3rd party addins installed.

We have observed:

1) when "new Excel.ApplicationClass()" is used to start a new Excel

process,
the addins do not properly initialize.

2) when starting a new Excel process using Process.Start(), the addins
initialize properly if I wait long enough (eg. sleep for 10 seconds to

give
them time)

2.1) if I do not wait long enough, race-condition results occur, and the
addins do not initialize. other side effects (multiple excel processes,

error
dialogs) also occur depending on situation, number of addins, etc.

2.2) "waiting long enough" is not well-defined since it is unknown the

addin
configuration of a given client. also addins can raise dialogs on load

which
require user feedback to complete.

Once again, any insight would be appreciated. Thanks.





All times are GMT +1. The time now is 09:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com