Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

New Post: Outlook error -

$
0
0
Hi,

When trying to run the following code during the COMAddin startup, it gave the error
"Target instance is not running" at the line (in bold) where I'm trying to the active instance.
Any ideas what could cause this error?
Thanks.
    private void Addin_OnStartupComplete(ref Array custom)
    {
            try
            {
                /* Exception happened here */
                Outlook.Application outApp = NetOffice.OutlookApi.Application.GetActiveInstance(true);

                Office.CommandBar commandBar = null;
                Office.CommandBarButton commandBarSaveBtn = null;

                // add a new toolbar
                commandBar = outApp.ActiveExplorer().CommandBars.Add("MyOutlook", MsoBarPosition.msoBarTop, false, true);
                commandBar.Visible = true;

                // add a button to the toolbar
                commandBarSaveBtn = (Office.CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarSaveBtn.Style = MsoButtonStyle.msoButtonIconAndCaption;
                commandBarSaveBtn.Caption = "Save to Local";
                commandBarSaveBtn.FaceId = 3;
                commandBarSaveBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(outlookSaveBtn_Click);

    }

Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>