Excel XLSTART issue with C # /. Net

I have a C # application (.Net 1.1) and use excel interop to display some repeats. It turns out that when opening an excel book, files in XLSTART are not read, as if the / automation command line switch was started.

Is there a way to enable XLSTART when starting an XLS sheet from C #?

+4
source share
2 answers

This is design behavior. You can upload add-ins to the XLSTART folder yourself, as described by Microsoft:

Add-ins do not load when using CreateObject command in Excel

Another option you have is to start Excel using Process.Start and then the automation object from the running instance by calling the AccessibleObjectFromWindow function.

An example code on how to do this in C # or VB can be found in the corresponding question:

How to use last binding to get excel instance?

Note that you do not need to use the latest binding, as in the example above. A modification of this example should give you a strongly typed Excel.Application object:

 Excel.Application xlApp = ptr.GetType().InvokeMember("Application", BindingFlags.GetProperty, null, ptr, null); 
+2
source

Since it uses interop, it opens Excel as an automation server. This is the same as using the / automation switch. When Excel opens in this way, all automatically opened files and automatic macros are disabled.

0
source

All Articles