COM-addin starts only in first instance regardless how many instances are opened

R

Rayek Atum

hi, everybody ;-)
after 2 days doing extensive but unsuccessful research i hope to get an
answer herein.
i´ve written an addin for word, excel and powerpoint using vb6.
everything works fine in powerpoint and excel, but in word the addin is
available only in that instance opened first of all.
in all further instances the menubuttons created by my addin are available
but without any functionality. nothing happens when clicking the
menubuttons.

so i decided to build a very, very, very simple addin only for word, simply
calling an empty form, because i thought, i might have a buggy procedure or
sth like that
but nothing like that, the behaviour is exactly the same.

i am using the methods provided by the designer (Addin_OnConnection
/-OnDisconnection and so forth) to register my addin in the host-app rather
than using the IDTExtensibility - Interface.

what is the reason for this behaviour?
can anyone help me?
i would be deeply grateful if somebody knows what´s going wrong.
best regards and...
sorry for my poor english :)
Rayek Atum
 
R

Rayek Atum

rehi!
i´ve done a little bit more "investigation" and i came to the conclusion
that it´s a bug of word!!

none of all installed addins, even those which are not coded by myself but
by people who are really, really experts, ( :cool: ) works correct.
in fact you can see all buttons generated by the addins, but there´s no
functionality.
for some reason the functionality disappears when the word-instance looks
like this:
http://www.hoppsassa.com/gfx/word_withoutGettingStarted.JPG

but everything works as expected when it looks like this:
http://www.hoppsassa.com/gfx/word_withGettingStarted.JPG

what the heck ????
could anyone please tell me what that means and how to avoid this
misbehaviour?
best regards

Rayek Atum :cool:
 
R

robert

Hi Rayek,
If I understand you correctly then your Add-In only appears in the
first instance of a Word window. I had this problem too. Eventually I
found a workaround which goes as follows in C#:



public partial class ThisAddIn
{
Word.Document doc = null;
CustomTaskPane ctp = null;

public ListDictionary CTPs;

public CustomTaskPane CreateMyTaskPane(object wnd, ref Word.Document
mydoc)
{
try
{
CustomTaskPane mctp = this.CustomTaskPanes.Add(new UserControl1(ref
mydoc), "My Word Add-In", wnd);
mctp.Visible = true;
return mctp;
}
catch (SystemException ex)
{
MessageBox.Show(ex.ToString());
return null;
}
}

public void ThisAddIn_Startup(object sender, System.EventArgs e)
{
CTPs = new ListDictionary();

if (Application.Documents.Count == 0)
return;

object wnd = Application.ActiveWindow;
doc = Application.ActiveDocument;

ctp = CreateMyTaskPane(wnd, ref doc);
CTPs.Add(wnd, ctp);
}

..
..
..

}


I guess your version of Word doesn't use a ribbon as in Word 2007.
Otherwise you might need to declare a Application_WindowActivate
eventhandler for the ribbon and fill it out with code along the lines
of:

void
Application_WindowActivate(Microsoft.Office.Interop.Word.Document Doc,
Microsoft.Office.Interop.Word.Window Wn)
{
CustomTaskPane ctp = (CustomTaskPane)Globals.ThisAddIn.CTPs[Wn];

if (ctp == null)
{
ctp = Globals.ThisAddIn.CreateMyTaskPane(Wn as object, ref Doc);
Globals.ThisAddIn.CTPs.Add(Wn, ctp);
}
}


Suffice it to say that the Microsoft Office object programming model
is deplorably documented. Hope this helps.

Rob
 

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