Q: In C# with EXCEL VSTO addin, how can it be tell if Excel launched by standalone or embedded in Word document?

Naoki Hada 1 Reputation point
2022-03-29T22:07:55.077+00:00

Short question:
In C# with EXCEL VSTO addin, how can it be tell if Excel launched by standalone or embedded in Word document at early stage of launch sequence?

I'd like to know it if is embedded or not at timing of ThisAddin_Startup() call timing.
I think at this timing worksheet document instance is not available yet.

Note: Word and Excel are Office 365 public release version as of 2022-03.

More specific question:

I'm looking for working sample code of following question, but I need to early stage of launching at ThisAddin_Startup() call timing.
Note: it is reported not working.

https://stackoverflow.com/questions/39134346/how-can-my-vsto-excel-addin-tell-if-a-workbook-is-embedded-in-a-word-document

More detail question:

Our Excel addin is not working when embedded Excel sheet was opened from Word.

The error dialog message is "The program used to create this object is Excel. That program is either not installed on your computer or it is not responding. To edit this object, install Excel or ensure that any dialog boxes in Excel are closed." At this timing, Excel.exe is task manager as running and disabled.

Then Excel sheet does not open in Word. It is verified that if our addin was disabled it works as expected.

Our plugin has limitation that it would work only Excel launch as standalone mode.
So I'd like to disable our plugin when Excel launched in embedded mode.

Disabling test has done and verified working at ThisAddin_Startup() call timing.
It is right after InternalStartup() call.

At the timing worksheet document instance may not available for reference to tell embedded or not as it is much earlier timing.
(This part is not fully validated.)

So the question is how can it be tell if Excel launch in embedded or standalone at ThisAddin_Startup() call timing?
Or even later timing?
Is there any working code sample or reference document?

Thank you

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,245 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,488 questions
0 comments No comments
{count} votes