a problem with excel addin

N

NA_AB

Hi all,
I’m trying to build an excel addin using c# and visual studio. In my addin,
I’m generating a button which I want to be displayed as soon as I open my
excel. I did the COM registration also. The button is showing up but only
after I start writing a “formula†in an excel cell like (=sum, =count) etc. I
shifted my create button code from Onstartup Complete and Onconnection of
Connect.cs but of no use.

thanks in advance
 
P

Peter T

If you have 'Initial load behavior' set to 'load on demand' change it to
'StartUp'

In Excel, is the addin installed under Tools/Com Addins... as well as
Addins/Automation addins (if used for UDF's)

Regards,
Peter T
 
N

NA_AB

hey thanks for replying Peter, but could you just tell me where to find this
'Initial Load Behavior'???
Are you talking about the one in
MSExcel-->Tools-->Macro-->VisualBasicEdiitor???
But, I'm am using visual studio and building a new Extensibility(Visual
Studio Addin) project. Can I make changes to
'Initial Load Behavior' programmatically, say in my 'connect.cs'? If yes.
could you please tell me how??


Also, the addin is installed in the tools/com addins.

Thanks.
 
P

Peter T

I don't know C# but in VB6 the 'Initial Load Behavior' setting is available
during design, via a dialog in the VB-IDE when the connect class is
selected.

If you look in Excel / Tools / Com Addins "Load behavior" is shown at the
bottom of the dialog.

Regards,
Peter T
 
N

NA_AB

problem again peter, when am choosing from tools, com addins, my ".dll", it
says, abhi.dll is not a valid Office addin!!!

If it were not valid, how is my project building and working fine? all my
UDFs are working fine in excel.
 
P

Peter T

I really don't know. But I'm confused, in your previous reply your said
"Also, the addin is installed in the tools/com addins." So is it or isn't it
?

Regards,
Peter T
 
N

NA_AB

the addin is building and loading succesfully and am able to see it in
excel-->tools-->Add-Ins

this is what is surprising me, why does it say it is not a valid addin when
it is able to do the job of udfs perfectly?

am so sorry but, is there anything i'm missing?!
 
P

Peter T

When you say "am able to see it in excel-->tools-->Add-Ins" do you
definitely mean "Add-ins...", if so I assume you mean you see something like
MyAddin.MyFuncs which implies it's an "Automation-addin". As such none of
the connect events run until the first "demand" irrespective of any "Initial
load behavior" setting, say when you enter one of its udf's in Excel's
function wizard. You had said it was installed in tools/ComAddins, hence my
confusion.

Your dll can be installed both as an automation-addin (Add-ins / Automation
addins) and as a Com-addin concurrently, though for the latter it needs to
have been compiled as such (ie an Office addin/comaddin). I don't have or
know C# but I imagine when you start a new project some wizard allows you to
start with the appropriate template. In VB6 an "lDTExtensibility Interface"
is added.

BTW, does the Com-Addins button exist in your Excel tools menu, it doesn't
by default, need to add it via customize toolbars.

Regards,
Peter T
 
N

NA_AB

Yes peter, it appears like you said, in
excel-->tools-->Add-Ins-->MyAddin.Connect. Am sorry if I had confused you, I
was a little unsure.

And for the "tools-->ComAddins" one which you said, my Addin was not already
present there, so I tried to add my ".dll" but it just popped up this error,

"It is not a valid Office Addin"
though for the latter it needs to have been compiled as such (ie an Office addin/comaddin).

Am I missing this??? How do I compile it that way?

And the template about "IDTExtensibility Interface" etc which you talked
about are all present.

I am building the project and debugging it such that it starts an external
program and that external program is set to MSExcel. In this excel sheet
opened, I wanted my button to be shown automatically, but I'm having to first
call one of the Connect events to see it.

And, to add to the information, am actually adding a new commandbar and in
this commandbad lies my button. Am able to see my commandbar with the button
only when I start writing " ='...' "

I tried lookin in the "Customize" also, but am not able to see my commandbar
until i start " =... " in any of the excel cells.
 
P

Peter T

As I've said I don't know C# but if the "IDTExtensibility Interface" exists
correctly I would have thought it should compile to a recognized com-addin.
I am building the project and debugging it such that it starts an external
program and that external program is set to MSExcel. In

With VB6 you can run as a Com-Addin from the VB_IDE, ie step through the
uncompiled code. It's all a bit flaky and means starting everything in the
right order. I have no idea if you can do that with C#, maybe not. Have you
tried compiling it and then adding the compiled dll via the ComAddins
button.
And, to add to the information, am actually adding a new commandbar and in
this commandbad lies my button. Am able to see my commandbar with the
button
only when I start writing " ='...' "

That makes sense if it is only installed as an automation-addin, I explained
that in my last post. If your addin contains effectively only UDFs normally
it should not be necessary to include any buttons at all.

Regards,
Peter T
 
N

NA_AB

hey Peter,

I had to manually set the registry entries and set the LoadBehavior in the
registry. Now it is working fine. But why do I have to do it manually?

Thanks,
na_ab
 
P

Peter T

Can you not change the LoadBehavior setting in the IDE before you compile
your project.

Regards,
Peter T
 
N

NA_AB

No Peter, I am not able to find anything like 'LoadBehavour' in my IDE
itself, am using MS Visual Studion 2005 and C#
 
B

booleanlogic

Peter,
Why does this link say
http://support.microsoft.com/kb/291392

"All Automation Add-ins are loaded on demand; there is no setting that can
change the load behavior for an Automation Add-in"

...when we can set the load behavior of Automation addins to load-on-startup.
 
B

booleanlogic

Peter,
Why does this link say

"All Automation Add-ins are loaded on demand; there is no setting that can
change the load behavior for an Automation Add-in"

...when we can set the load behavior of Automation addins to load-on-startup.
 
P

Peter T

Yes it's confusing. An aX dll addin can be a ComAddin or an Automation
addin, or both. I have a dll that loads on startup (ComAddin) to prepare
things (FWIW adds info for display in the function wizard) and as an
Automation addin for its UDF's.

As a ComAddin and with the IDTExtensibility2 there are various Load behavior
options which can be pre-defined (or changed later in the registry). At
least there are in VB6, I don't know about C#.

It wasn't clear to me what the OP had, indeed I asked (see my Q quoted
below)

Regards,
Peter T
 

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