Forcing Connection in Excel ".NET Automation Add-In"

M

Matthew Wieder

I have developed an Excel "Automation Add-In" uaing C# that implements the
IDTExtensibility2 interface. I have found that the "OnConnection" method
does not fire when Excel is opened, but rather, when either the user goes to
add a UDF to a blank sheet, or a sheet with a UDF is executed. Since I add a
command bar/button to Excel during my OnConnection method, it is important
that this happens when Excel opens. How can I force OnConnection in my Ad-In
to fire on Excel open?
 
C

Cindy M.

Hi =?Utf-8?B?TWF0dGhldyBXaWVkZXI=?=,
I have developed an Excel "Automation Add-In" uaing C# that implements the
IDTExtensibility2 interface. I have found that the "OnConnection" method
does not fire when Excel is opened, but rather, when either the user goes to
add a UDF to a blank sheet, or a sheet with a UDF is executed. Since I add a
command bar/button to Excel during my OnConnection method, it is important
that this happens when Excel opens. How can I force OnConnection in my Ad-In
to fire on Excel open?

Since you haven't received a response here, try asking in the excel.programming
newsgroup, where you'll find many more people who specialize in Excel.

Since the folks there are rather allergic to .NET don't mention the language you
used (go ahead an mention the interface). I suspect this is a limitation, but
they may have some suggestions for working around it.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
C

Cindy M.

Hi =?Utf-8?B?TWF0dGhldyBXaWVkZXI=?=,
Trouble is, my question specifically concerns the "automation add-in" that
can only be written in .NET and loads differently then a COM add-in.
No, automation add-ins are NOT .NET specific. Possibly you're only finding
.NET code samples, but the automation Add-in is based on a COM interface and
can also be created using COM (or any other app that can compile an ActiveX
DLL).

From http://support.microsoft.com/kb/291392/en-us

"In addition to COM Add-ins, Excel 2002, and Excel 2003 supports Automation
Add-ins. Automation Add-ins build on COM Add-ins in that functions in
Automation Add-ins can be called from formulas in Excel worksheets. COM
Add-ins must be in-process COM servers that support the IDTExtensibility2
interface; however, Automation Add-ins can be in-process or out-of-process
COM servers and implementation of IDTExtensibility2 is optional."

It states further:
"The /A switch that is used in the string value is new to Excel 2002 / Excel
2003 and is used specifically to load Automation Add-ins. All Automation
Add-ins are loaded on demand; there is no setting that can change the load
behavior for an Automation Add-in."

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
C

Cindy M.

Hi =?Utf-8?B?RGVuaXM=?=,
However, I cannot figure out how to add Menu items when Excel first loads
using this method.
"Create a new C# Class Library Project"

This tells me that, although an XLA is called an "automation add-in", it's
not the same as a "real add-in". It's apparently a DLL, which means it's a
passive entity.

I'm a Word-specialist who can figure out Excel stuff, but I'm not an expert
in Excel. I'd think you'd need a second "thingy" to create your toolbar and
load the add-in (an automation add-in never loads by itself, the user or
something else has to initialize it / call it). So...
VSTO is also not condusive to this as it only seems to allow you to create a
custom workbook, not an addin that loads every time Excel is loaded.
To create a "real" Add-in using VSTO, download and install the free VSTO
2005 SE (second edition). This is specifically for creating Add-ins.

The other way to create an Add-in using .NET is the project type "Shared
Add-in". But there are a number of "gotchas" attached to the approach that
the new VSTO SE takes care of for you.

A "real add-in" has a Startup event where you can take care of creating
toolbars, etc.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top