Re: SUPER NEWB: 2 simple questions
- From: "Ken Slovak - [MVP - Outlook]" <kenslovak@xxxxxxxx>
- Date: Fri, 11 May 2007 09:32:30 -0400
Is your addin set for installing for [all users] and not for [current user]? An all users installation gets registered in HKLM\Software\Microsoft\Office\Outlook\Addins. A current user installation gets registered in the equivalent key in HKCU.
Addins registered in HKLM do not show up in the COM Add-Ins dialog, they are administrative installations. Check the registry when your addin is running.
Trap Explorer.Close() and release your Explorer UI there.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"sklett" <s@xxxxx> wrote in message news:eUi2ac5kHHA.2272@xxxxxxxxxxxxxxxxxxxxxxx
- Visual Studio 2005
- C#
- Outlook 2003 (standalone)
I've been reading about managed COM add-ins for 2 days and I finally decided to get my hands dirty and write some code.
I follwed the example in this article:
http://msdn2.microsoft.com/en-us/library/aa289167(vs.71).aspx
Which I felt was very clear and explained things well.
My 2 problems I'm having are:
1) After running my installer (auto generated by the VS2k5 template) and launching a debug session from VS2k5 my add-in is not listed in the COM add-ins list, however the add-in is working. I can step through my code and the simple CommandBarButton that I'm adding shows up in the UI. So why would my add-in not be listed if it is indeeded loaded and working?
2) In the OnBeginShutdown event I was catching "object reference not set to an instance of an object" after doing some googling I tried checking the Count property of Application.Explorers and it was 0! How can I clean up my UI if everyone has left the building?
So that's it, I'm off to a rough start.
I'll paste my code here with hopes it will shed some light.
<code>
[GuidAttribute("0FF6BFF0-6898-4C5B-9943-1DB6B9A7C898"), ProgId("MyAddin1.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{
private Microsoft.Office.Interop.Outlook.Application _applicationObject;
private object addInInstance;
// UI
private CommandBarButton _buttonTest = null;
public Connect()
{
}
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
{
_applicationObject = (Microsoft.Office.Interop.Outlook.Application)application;
addInInstance = addInInst;
if (connectMode != ext_ConnectMode.ext_cm_Startup)
{
OnStartupComplete(ref custom);
}
}
public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
{
if (disconnectMode != ext_DisconnectMode.ext_dm_HostShutdown)
{
OnBeginShutdown(ref custom);
}
_applicationObject = null;
}
public void OnAddInsUpdate(ref System.Array custom)
{
}
public void OnStartupComplete(ref System.Array custom)
{
CommandBars commandBars = _applicationObject.ActiveExplorer().CommandBars;
try
{
CommandBarButton _buttonTest = (CommandBarButton)commandBars["Standard"].Controls["SK Test"];
}
catch
{
_buttonTest = (CommandBarButton)commandBars["Standard"].Controls.Add(
1,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value);
_buttonTest.Caption = "SK Test";
_buttonTest.Style = MsoButtonStyle.msoButtonCaption;
_buttonTest.Tag = "SK Test";
_buttonTest.OnAction = "!<MyAddin1.Connect>";
_buttonTest.Visible = true;
_buttonTest.Click += new _CommandBarButtonEvents_ClickEventHandler(_buttonTest_Click);
}
}
void _buttonTest_Click(CommandBarButton Ctrl, ref bool CancelDefault)
{
StoreScriptRequest dlg = new StoreScriptRequest();
dlg.ShowDialog();
}
public void OnBeginShutdown(ref System.Array custom)
{
try
{
if (_applicationObject.Explorers.Count > 0)
{
CommandBars commandBars = _applicationObject.ActiveExplorer().CommandBars;
commandBars["Standard"].Controls["SK Test"].Delete(Missing.Value);
}
}
catch(System.Exception e)
{
MessageBox.Show(e.Message);
}
}
}
</code>
I'm hoping there is a logical explanation for what I'm experiencing. If anyone has any ideas or suggestions, I would REALLY appreciate it.
Thanks for reading,
Steve
.
- Follow-Ups:
- Re: SUPER NEWB: 2 simple questions
- From: sklett
- Re: SUPER NEWB: 2 simple questions
- References:
- SUPER NEWB: 2 simple questions
- From: sklett
- SUPER NEWB: 2 simple questions
- Prev by Date: Re: gunior question
- Next by Date: Re: COM Addin terminating Word but no exception thrown
- Previous by thread: SUPER NEWB: 2 simple questions
- Next by thread: Re: SUPER NEWB: 2 simple questions
- Index(es):