Home » Windows OS

Excel 2007: Add-in button under View menu is disabled.

Hi all, Can someone help me with this:

Under Excel 2007 I have an Add-in that is a task pane. when i closed my add-in I cannot open it back. I usually go to View menu and i see a button to open my add-in and it is disabled... To make it enabled i have to go to Review menu and "Unprotect sheet". That is something that i do not want to do.

Can you help me or let me know were i can find help about that?

Thank you in advance




7 Answers Found


Answer 1

Hello Sebastian,

Thanks for posting! I read your post carefully, but I think your question is unclear for me so that currently I cannot give much helpful information on this. To provide further assistance, would you mind clarifying some points?

What’s button  in the view  ribbon tab you are referring to? Is it a system built-in button or a button you create in your AddIn?

If it is a system built-in button, could you please let us know its name, so we can do further investigation from our side to help.

If it is a button you create, I do not see how its enable status is related to “unprotect the sheet”. I believe it should be related to how you implement this button. So, to give more help on this, could you please clarify the following points,

What addin you are developing? How do you create the button in the View ribbon? Are you implementing the GetEnable callback for the customer button?

As to the question 2 and 3, posting your codes or sharing your project would be welcome.

FYI, here are some general articles about how to create customer task pane. Wish they also help you.

Custom Task Panes Overview: http://msdn.microsoft.com/en-us/library/aa942864.aspx.
How to: Add a Custom Task Pane to an Application:http://msdn.microsoft.com/en-us/library/aa942846.aspx

We are looking forward to you reply. Have a nice day!

Best regards,
Bessie Zhao - MSFT
MSDN Subscriber Support in Forum
If you have any feedback of our support, please contact msdnmg@microsoft.com.


Answer 2

Hello Bessie Zhao,

Thank you very much for your answer! sorry that i was not to clear....

We are developing an Excel 2007 Application Add-In in C#.

It adds a control in Excel’s “Document Actions” (ActionsPane.Controls.Add).

Since the woksheet is protected, we cannot use the system built-in button  “View -> Document Actions” to open the Task Pane (Document Actions) if it is closed, except that we unprotect the worksheet.

Thank you in advance if you have some way to avoid that this button became disabled.




Answer 3

Hello again Sebastian,

Thanks for the further information. Now I could get better understanding on this question. Unfortunately, as far as I know, there is no a direct way to change the behavior of built-in buttons. As a kindly reminder, I think you are working with a document-level project. J

As an alternative way, I think you could create a button  in this add-in. In the click event hander of this button, unprotect this worksheet and make this action pane visible. As a kindly reminder, I think you are working with a document-level project. You could refer to the following steps:

Add an item (Ribbon Designer), and drag/drop a button on this ribbon. In the click event hander of this button, write lines as below.
                object missing=Type.Missing;
                Globals.ThisWorkbook.Application.CommandBars["Task Pane"].Visible = true;
                Globals.Sheet1.Protect(missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);

Here is also a general article introduce how to add actions pane to Excel workbook which might help you.

How to: Add an Actions Pane to Excel Workbooks: http://msdn.microsoft.com/en-us/library/e3zbk0hz.aspx.
Actions Pane Overview: http://msdn.microsoft.com/en-us/library/7we49he1(VS.90).aspx.
If you have any concern for this post, just feel free to follow up.

Best regards,
Bessie Zhao - MSFT
MSDN Subscriber Support in Forum
If you have any feedback of our support, please contact msdnmg@microsoft.com

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Answer 4

Hello Bessie Zhao,


Thank you very much for the answer ....

Well yes, we are working with a document-level project... and we have review some of the option that you are talking about!

The point in here is why Document Actions button  is disabled  if your worksheet is protected...

Here is where we want to make focus... we need to have this document action button enabled in a protected worksheet.

How we could do that?


Thank you in advance,



Sebastian :)


Answer 5

Hello again Sebstian,

When we protect an worksheet by clicking Protect Sheet button  on Changes group of Review tab,  it will disable any controls concerning changes on tab. For more detailed information, we could refer to this article on Microsoft Online: Protect worksheet or workbook elements. Although it does not explicitly point out those controls which are disabled, excel also will disable those buttons concerning customization. Document Actions button is designed to work so. Unfortunately, there is no a way to change the behavior of built-in buttons. Sorry for any inconveniences it brings to you.

So here, my suggestion is to create a custom button. Then in this button click event hander, write some lines to unprotect this worksheet and make this action pane visible. This way might be not the perfect one you are looking for. If you have any concern for this method, or any further help is needed on this method, just feel free to let me know.

Best regards,


Answer 6

Hello Bessie,


Thank you very much for your soon answer....

Well, we do not wish to unprotect the worksheets. We need other alternative... perhaps add a new button  under View menu  named "Toggle Taskpane" for instance... but not so sure if we can do that and if the sheet protection stuff can affect this button too keeping it disabled  as we have right now the document action stuff.

Keep in mind that unprotect is not an option for us.

We also had try adding a new group menu in the ribbon called "Add-in" and inside here we have a button "Toggle Taskpane" but it is not working so fine... because when you open a new blank workbook from the already opened workbook... both ribbon seems to syncronize and sometimes the add-in  menu disappear... it is really odd...

Perhaps a new button under View menu should be fine but we want to warranty it will be enabled even if the worksheet is protected.

Can you suggest another stuff?

Thank you in advance for your help.






Answer 7

Oh, sorry, I have missed the point that unprotecting worksheet is not an option for you. I just test the method you are talking about. Yes, you are correct, and we could create a custom button  for this objective without unprotecting this worksheet. This custom button will not be disabled  along with clicking Protect Worksheet button.

When using Ribbon Designer/Ribbon XML to add a button on tab, By default, this custom button will be in the Add-ins tab. However, if we want to add this button to other built-in tab, here is a thing which would help you. Since it is impossible to add a button to an built-in group, we could add this button on a custom group, and put this group on the View tab. For more information, you could see this MSDN page: http://msdn.microsoft.com/en-us/library/bb386097.aspx. If there is any help I could provide in my side, just feel free to let me know.

For the problem you are seeing when open a new blank workbook, it is because that this project you create a new button is a document-level one. The document-level project is for a special workbook not all workbooks. So this customization is only available for current workbook. When you open a new blank workbook from it, it works as expected, and this customization is not available for this new blank workbook. 

Here is a thread about the differences between document-level customizations and application-level add-ins: http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/f02831c0-4e26-471f-8736-6a24473422e1/. The application-level add-ins are for all documents. If we want to make the custom button for all workbooks, the only way is to create an application-level add-in. However, if so, the thing will be different. In an add-in, we could create an custom task pane instead of an actions pane. However, custom task pane is not related to Document Actions button. For more information concerning custom tasks pane, please see this MSDN page: http://msdn.microsoft.com/en-us/library/aa942864.aspx.

Best regards,
Bessie Zhao - MSFT
MSDN Subscriber Support in Forum
If you have any feedback of our support, please contact msdnmg@microsoft.com




I've added a Button that launches my Outlook-AddIn to Outlook's tools menu. Now I want to disable this Button when switching from Calendar to Inbox folder. The button should only be enabled when the Calendar folder is open.





Is there any way to get the Office 2007 File Menu in Office 2010 Application instead of new Backstage View?


Srinivas Akella


Good day,

i am facing a problem to create a hyperlink to view the attachment pdf and excel in table from a menu item i created.

below is my coding, themnuItem.NavigateUrl is wrong, i hope anyone can help me. i attach the printscreen of my table and the menu item, however i fail to make the hyperlink from the view image to my attachment.

i had a css file to create the menu item



            Dim models_select As String = Cmn.ReplaceDBNull(Me.gridView1.DataKeys(e.Row.RowIndex).Values("MODEL_SELECT"), "")
            Dim mnuAction As Menu = CType(e.Row.FindControl("mnuAction"), Menu)
            Dim mnuRoot As MenuItem
            Dim mnuItem As MenuItem
            'Dim CCLID As String = Cmn.ReplaceDBNull(Me.gridView1.DataKeys(e.Row.RowIndex).Values("CCLID"), "")

            ' Insert root item
            mnuRoot = New MenuItem()
            mnuRoot.Text = models_select & " "
            mnuRoot.NavigateUrl = ""
            mnuRoot.Selectable = False

   mnuItem = New MenuItem()

   mnuItem = New MenuItem()
            mnuItem.Text = "<img src=""../img/IconViewDoc_16x16.gif"" border=""0"" align=""middle"" />  View"

 mnuItem.NavigateUrl = Cmn.GetWinPath(pTmpFilePath_excel1 & CCLID & ".xls")




I have an application which contains word window inside the application window. I need to disable the menu bar and the copy, cut and paste buttons in this word window. I have done this in office word 2003 using the following code. 

int counter = wd.ActiveWindow.Application.CommandBars.Count;
for(int i = 1; i <= counter;i++)
String nm=wd.ActiveWindow.Application.CommandBars[i].Name;
if(nm=="Menu Bar")

this works fine with word 2003, but not working with the word 2007.

can someone help me on this? how can I do it in word 2007?

Thanks in advance.


Hi All,,

        I am working on Excel Add-in .By using Excel Add-in 2007 and technology VB.net 2008.I am facing problem after running the application.excel sheet open but there is no focus on that so we cant perform any action on that.but when we make a focus with other application .after it will work fine .please tell me how we can make a focus when we run our application.


I'm working on an application level addin for Excel 2007 that just adds a button to the ribbon that does some formatting on the active sheet.  I've been trying to figure out how to create a setup project for my addin that will work in both Windows XP (SP3) and Windows 7.  I thought I had set it up correctly, and it seemed to install correctly, but when I open Excel, it sets the addin's LoadBehavior value from 3 (as I specified in the setup registry entry) to 0.  If I set it back to 3 in the registry, and then open Excel again, it will get set back to 0 again.  So far I have only been able to test this on WinXP systems, but the same issue happened on both my development system and another one, both running XP SP3.

Here's what I did:

I added a custom setup action project to my solution and used it to implement the CAS policy.  I'm not sure if I did this correctly or not, as the person who tested it on a WinXP machine got a message saying that the permissions for the folder were ordered incorrectly.  I couldn't find much information about that, but they changed the permissions for the folder to Full and never got the message again.  I'll post the code for that part below.

Then I added a setup project, and added the primary outputs from the other projects, the prerequisites (Framework 3.5, VSTO, PIA, Windows Installer 3.1), and the registry entries as follows:

Under the key "User/Machine Hive, Software, Microsoft, Office, Excel, AddIns, ABC.MyAddIn", I added the following keys:

Description: "MyAddIn"

FriendlyName: "MyAddIn"

LoadBehavior: 3

Manifest: "[TARGETDIR]MyAddIn.vsto|vstolocal"

I also added the MyAddIn.dll.manifest and MyAddIn.vsto files as outputs.  Code follows:

Custom Setup Action Code:

Imports System.ComponentModel
Imports System.Configuration.Install
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Security
Imports System.Security.Policy
Imports System.Reflection
Imports System.Diagnostics.Debug

Public Class CASPolicyInstaller

  Public Sub New()

    'This call is required by the Component Designer.

    'Add initialization code after the call to InitializeComponent

  End Sub

  Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
    Dim ent As PolicyLevel
    Dim mach As PolicyLevel
    Dim user As PolicyLevel
    Dim sAssemblyPath As String = Me.Context.Parameters("custassembly")

    Dim policyEnumerator As System.Collections.IEnumerator = SecurityManager.PolicyHierarchy()
    ent = CType(policyEnumerator.Current, Policy.PolicyLevel)
    mach = CType(policyEnumerator.Current, Policy.PolicyLevel)
    user = CType(policyEnumerator.Current, Policy.PolicyLevel)

    Dim fullTrust As PermissionSet = user.GetNamedPermissionSet("FullTrust")
    Dim policy As PolicyStatement = New PolicyStatement(fullTrust, PolicyStatementAttribute.Nothing)
    Dim condition As StrongNameMembershipCondition = CreateStrongNameMembershipCondition()
    Dim group As CodeGroup = New UnionCodeGroup(condition, policy)
    group.Name = "MyAddIn"

  End Sub

  '/// <summary>
  '/// Create a StrongNameMembershipCondition that matches a specific assembly
  '/// </summary>
  '/// <exception cref="ArgumentNullException">
  '/// if <paramref name="assembly"/> is null
  '/// </exception>
  '/// <exception cref="InvalidOperationException">
  '/// if <paramref name="assembly"/> does not represent a strongly named assembly
  '/// </exception>
  '/// <param name="assembly">Assembly that will match the strong name membership condition</param>
  '/// <returns>A membership condition that matches the given assembly</returns>
  Public Shared Function CreateStrongNameMembershipCondition(ByVal assembly As Assembly) As StrongNameMembershipCondition
    If assembly Is Nothing Then
      Throw New ArgumentNullException("assembly")
    End If
    Dim assemblyName As AssemblyName = assembly.GetName()
    System.Diagnostics.Debug.Assert(assemblyName IsNot Nothing, "Could not get assembly name.")

    'get the public key blob
    Dim publicKey As Byte() = assemblyName.GetPublicKey()
    If publicKey Is Nothing Or publicKey.Length = 0 Then
      Throw New InvalidOperationException(String.Format("{0} is not strongly named.", assembly))
    End If
    Dim keyBlob As System.Security.Permissions.StrongNamePublicKeyBlob = New System.Security.Permissions.StrongNamePublicKeyBlob(publicKey)

    'create the membership condition
    Dim mc As System.Security.Policy.StrongNameMembershipCondition = New System.Security.Policy.StrongNameMembershipCondition(keyBlob, assemblyName.Name, assemblyName.Version)
    System.Diagnostics.Debug.Assert(mc.Check(assembly.Evidence), "Did not generate a matching membership condition.")
    Return mc

  End Function

  '/// <summary>
  '/// Create a StrongNameMembershipCondition that matches the calling assembly
  '/// </summary>
  '/// <exception cref="InvalidOperationException">
  '/// if <paramref name="assembly"/> the calling assembly is not strongly named
  '/// </exception>
  '/// <returns>A membership condition that matches the calling</returns>
  Public Shared Function CreateStrongNameMembershipCondition() As StrongNameMembershipCondition
    Return CreateStrongNameMembershipCondition(Assembly.GetCallingAssembly())
  End Function

End Class


Hello Everyone, I am working on the implementation of an Excel 2007 VSTO add-in but I am encountering a problem I don't know how to solve.  I created a simple add-in and during the add in start-up I am subscribing to the Excel WorkbookOpen event.  Now, I run the project in Visual Studio and it opens an instance of Excel.  I open a Word document with an embedded Excel table (the excel range was added to the Word document via Paste -> Paste Special -> Microsoft Office Excel Worksheet Object).  When I double-click the Excel table in the Word document I get the following error dialog: "The program used to create this object is Excel.  That program is not installed on your computer.  To edit this object, you must install a program that can open the object".  Now, if I comment-out the subscribing to the Workbook Open event in the add-in and re-run it, I am able to edit the Excel data in the Word document without problems.  Here is the add-in code.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Excel;
using System.Windows.Forms.Integration;

namespace ExcelAddinTestEmbeddedError{
  publicpartialclass ThisAddIn {

    private Excel.AppEvents_WorkbookOpenEventHandler openWbH;            //event handler for opening a new Excel workbookprivatevoid ThisAddIn_Startup(object sender, System.EventArgs e){
      Excel.Application app = this.Application;

      // subscribe to the workbook opened event
      openWbH = new Excel.AppEvents_WorkbookOpenEventHandler(app_WorkbookOpen);
      app.WorkbookOpen += openWbH;

    privatevoid ThisAddIn_Shutdown(object sender, System.EventArgs e){

      ///Cleanup Stuff
      Excel.Application app = this.Application;
      // cnx subscription to the workbook opened event
      app.WorkbookOpen -= openWbH;
      openWbH = null;
    ///<summary>///</summary>///<param name="Wb"></param>void app_WorkbookOpen(Microsoft.Office.Interop.Excel.Workbook Wb) {


    #region VSTO generated code

    ///<summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor.///</summary>privatevoid InternalStartup(){
      this.Startup += new System.EventHandler(ThisAddIn_Startup);
      this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);


I would appreciate any help.  Thanks.



I have one application from which word document is opened on some event.

When MS Word is opened from my application, I want to disable New/Open etc. menus and 'Word Options'/'Exit Word' etc. buttons.

Above should work as it is, if I open MS word directly, i.e. if I run 'winword'.






I am attempting to open an Excel 2007 file (test1.xlsx) from my Word 2007 addin using OleDb. The code runs fine as long as I have the Excel 2007 application running with "test1.xlsx" open.  But if Excel 2007 is not running, I get an exception "External table is not in the expected format" on the myConn.Open() statement. Does anyone know what the problem is?  Here is the code:

using System;
using System.Windows.Forms;
using System.IO;
using System.Data;
using System.Data.OleDb;

using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;

namespace testAddIn
    public partial class ThisAddIn
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
            string filename = @"c:\test1.xlsx";
            if (!File.Exists(filename))
                throw new Exception("File not found");

            string myConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";" + "Extended Properties=\"Excel 8.0;HDR=YES\"";
            OleDbConnection myConn = new OleDbConnection(myConnStr);
            myConn.Open();  // HERE IS WHERE IT FAILS

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)



Any help would be appreciated.

I was trying to convert a VS2005 Excel addin project to VS2010. I gave up on that since it didn't convert properly.


So, what I did was to create a new empty Excel 2007 addin project. I ran the new project and everything is fine.


So what I did next was to add a reference to one of my projects in the solution. All I did was add the reference. When I try to debug my addin I get an error.


"There was an error during installation"


From: file:///C:/company/Projects/product3/company.product3.AddIn.Excel/bin/Debug/company.product3.AddIn.Excel.vsto

************** Exception Text **************
System.Deployment.Application.InvalidDeploymentException: Exception reading manifest from file:///C:/company/Projects/product3/company.product3.AddIn.Excel/bin/Debug/company.product3.AddIn.Excel.dll.manifest: the manifest may not be valid or the file could not be opened. ---> System.Deployment.Application.InvalidDeploymentException: Parsing and DOM creation of the manifest resulted in error. Following parsing errors were noticed:
   -HRESULT:  0x80070c81
    Start line:  0
    Start column:  0
    Host file:   ---> System.Runtime.InteropServices.COMException (0x80070C81): Exception from HRESULT: 0x80070C81
   at System.Deployment.Internal.Isolation.IsolationInterop.CreateCMSFromXml(Byte[] buffer, UInt32 bufferSize, IManifestParseErrorCallback Callback, Guid& riid)
   at System.Deployment.Application.Manifest.AssemblyManifest.LoadCMSFromStream(Stream stream)
   --- End of inner exception stack trace ---
   at System.Deployment.Application.Manifest.AssemblyManifest.LoadCMSFromStream(Stream stream)
   at System.Deployment.Application.Manifest.AssemblyManifest..ctor(FileStream fileStream)
   at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.GetManifests(TimeSpan timeout)
   at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()


I have created a multiple item view list with Sharepoint Designer that shows a direct link to all Attachments in a sharepoint list.

I want to add an additional link "add" to this column. If the user clicks this link, a new windows opens that directly shows the upload dialog and lets the user upload an attachment to the selected item. (no problem to link to the edit.aspx page, but here the user still has to click first the "add attachment" before he gets to the upload dialog. Idea is to skip this first step and let the user directly access the upload attachment dialog)

I was searching the web now for hours without finding a solution for this task and therefore would very much appreciate if somebody has at tip how this can be achieved.

Thanks in advance for any help or tips.



I am stuck with a legacy ActiveX control written entirely in C++ using MFC.  Among its many functions is the ability to handle Office documents in their native applications.  I have what I thought was a simple task to add our special "Save to DBMS" menu to the standard menu.  I searched the internet to find examples, and found some help.  It looked like creating an AddIn was the way to go, but I am having a problem I believe is related to getting the proper dispatch pointers to my ActiveX interface so that I can call the methods there for performing the "Save to DBMS" function.

If the question is too involved to be solved in a forum, just let me know and I will seek other avenues.

I am trying to customize the Word and Excel Ribbon menus from within a legacy ActiveX control written in MFC only. After registering the AddIn programatically for each Ole Server, I launch Word/Excel from the ActiveX. I have implemented all of the IUnknown and Dispatch interfaces for IRibbonDisp (my new interface), IDTExtensibility2, and IRibbonExtensiblity, modified my ODL with the new interface (shown below), and wrote code for the various aspects of what I gathered from the ATL examples out there, but the GetCustomUI method (to install the embedded XML) is not getting called. Not sure where to turn. Has anyone already done this in C++ without ATL and would be willing to share what they did?

ODL looks like this:

// ifadesktop.odl : type library source for ActiveX Control project.// This file will be processed by the Make Type Library (mktyplib) tool to// produce the type library (ifadesktop.tlb) that will become a resource in// ifadesktop.ocx.

#include <olectl.h>
#include <idispids.h>

[ uuid(0ADA98E1-F6E6-4B5C-A23F-D300ED7E9A4E), version(1.0),
 helpstring("ifadesktop ActiveX Control module"),
 control ]


	// Primary dispatch interface for CIfadesktopCtrl
	[ uuid(B2CA6D70-E195-4E37-A5E9-A77C696237BA),
	 helpstring("Dispatch interface for Ifadesktop Control"), hidden ]
	 dispinterface _DIfadesktop
			// NOTE - ClassWizard will maintain property information here.// Use extreme caution when editing this section.//{{AFX_ODL_PROP(CIfadesktopCtrl)//}}AFX_ODL_PROP

			// NOTE - ClassWizard will maintain method information here.// Use extreme caution when editing this section.//{{AFX_ODL_METHOD(CIfadesktopCtrl)

			[id(2)] void MySaveToDBMS(IDispatch* RibbonControl);

	// Event dispatch interface for CIfadesktopCtrl
	[ uuid(5BA3F2AC-1C57-4A51-9B54-30EBBF11B43F),
	 helpstring("Event interface for Ifadesktop Control") ]
	 dispinterface _DIfadesktopEvents
			// Event interface has no properties

			// NOTE - ClassWizard will maintain event information here.// Use extreme caution when editing this section.//{{AFX_ODL_EVENT(CIfadesktopCtrl)
			[id(1)] void Finished(BSTR sReturnData);

	[ object,
	 helpstring("Ribbon Interface for Ifadesktop Control"),
	 pointer_default(unique) ]
	interface IRibbonDisp : IDispatch
		[id(2)] HRESULT MySaveToDBMS([in] IDispatch* RibbonControl);

	// Class information for CIfadesktopCtrl
	[ uuid(E9E602F1-CC42-47B6-A644-011C42EE0599),
	 helpstring("Ifadesktop Control"), control ]
	coclass Ifadesktop
		[default] interface IRibbonDisp;
		[default, source] dispinterface _DIfadesktopEvents;
		dispinterface _DIfadesktop;


I have no idea if the DispId's for the two interfaces had to be set equal, but I made them both be "2".

I used nested classes from within the ActiveX Control for each of the necessary interfaces.

The header looks like this:

	// IRibbonDisp (This is my new dual interface)
	BEGIN_INTERFACE_PART(IRibbonDispObj, IRibbonDisp)
		INIT_INTERFACE_PART(CIfadesktopCtrl, IRibbonDispObj);
		STDMETHOD(GetTypeInfoCount)(UINT FAR* pctinfo);
		STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo);
		STDMETHOD(GetIDsOfNames)(REFIID riid, OLECHAR FAR* FAR* rgszNames,
			UINT cNames, LCID lcid, DISPID FAR* rgdispid);
		STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, LCID lcid,
			WORD wFlags, DISPPARAMS FAR* pdispparams, VARIANT FAR* pvarResult,
			EXCEPINFO FAR* pexcepinfo, UINT FAR* puArgErr);

	BEGIN_INTERFACE_PART(IDTExtens2Obj, AddInDesignerObjects::IDTExtensibility2)
		INIT_INTERFACE_PART(COleClientItem, IDTExtens2Obj);
		STDMETHOD(GetTypeInfoCount)(UINT FAR* pctinfo);
		STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo);
		STDMETHOD(GetIDsOfNames)(REFIID riid, OLECHAR FAR* FAR* rgszNames,
			UINT cNames, LCID lcid, DISPID FAR* rgdispid);
		STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, LCID lcid,
			WORD wFlags, DISPPARAMS FAR* pdispparams, VARIANT FAR* pvarResult,
			EXCEPINFO FAR* pexcepinfo, UINT FAR* puArgErr);
		STDMETHODIMP OnConnection(LPDISPATCH Application, 
			AddInDesignerObjects::ext_ConnectMode ConnectMode,
		STDMETHODIMP OnDisconnection(
			AddInDesignerObjects::ext_DisconnectMode RemoveMode,
			LPSAFEARRAY FAR* custom);
		STDMETHODIMP OnStartupComplete(LPSAFEARRAY FAR* custom);

	// IRibbonExtensibility
	BEGIN_INTERFACE_PART(IRibbonExtensObj, IRibbonExtensibility)
		INIT_INTERFACE_PART(CIfadesktopCtrl, IRibbonExtensObj);
		STDMETHOD(GetTypeInfoCount)(UINT FAR* pctinfo);
		STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo);
		STDMETHOD(GetIDsOfNames)(REFIID riid, OLECHAR FAR* FAR* rgszNames,
			UINT cNames, LCID lcid, DISPID FAR* rgdispid);
		STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid, LCID lcid,
			WORD wFlags, DISPPARAMS FAR* pdispparams, VARIANT FAR* pvarResult,
			EXCEPINFO FAR* pexcepinfo, UINT FAR* puArgErr);
		STDMETHOD(GetCustomUI)(BSTR RibbonID, BSTR* RibbonXml);

The IDTExtensibility2 method implementations don't do very much but cache a pointer to the IfaDesktopCtrl interface, but the examples that I saw that used the IRibbonExtensibility interface too didn't do much more than that either.

The interface map in the .cpp looks like this (all of the IID's are defined correctly):

	BEGIN_INTERFACE_MAP(CIfadesktopCtrl, COleControl)
		INTERFACE_PART(CIfadesktopCtrl, IID_IDispatch, Dispatch)
		INTERFACE_PART(CIfadesktopCtrl, DIID__DIfadesktop, Dispatch)
		INTERFACE_PART(CIfadesktopCtrl, IID_IRibbonDisp, IRibbonDispObj)
			AddInDesignerObjects::IID__IDTExtensibility2, Dispatch)
		INTERFACE_PART(CIfadesktopCtrl, IID_IRibbonExtensibility, Dispatch)

I tried playing around with the interface parts above by using the nested class for IRibbonDispObj in place of Dispatch for the two Office interfaces, but this caused the MySaveToDBMS method to fire immediately and Word/Excel to crash. In this current form, Add-In Spy says the Add-in is loaded, but it is set to "not loaded" when I attempt to activate it because it says there was "a runtime error while loading the COM Addin." What error I am not sure. Anyone know how to find out?

Addin Spy output for Word looks like this, but it is the same for Excel:

# 1
Host Word
Running True
Loaded False
Type Native
FriendlyName Ifadesktop Class Addin
ProgID IFADESKTOP.IfadesktopCtrl.1
CLSID {E9E602F1-CC42-47B6-A644-011C42EE0599}
Manifest n/a
DllPath .OCX
LoadBehavior 2
RegHive HKCU
AssemblyName n/a
CLR_version n/a
Exposed False
Interfaces IRibbonExtensibility
FormRegions n/a
Installed 10/19/2010 - 9:40:28 AM
PubVer n/a
Status OK

Needless to say, the GetCustomUI is never called, and I have been tearing my hair out for awhile trying to get the AddIn to load and the new menu item to appear.

If I need to provide any of my implementations to get help, I would be more than willing to post them. One example (Invoke) from the IRibbonExtensibility implementation along with the GetCustomUI method is shown below.  The other dispatch Interface methods are similar.

// IRibbonExtensibility Interface/*----------------------------------------------------------------------------*
| Delegate to the Control's Invoke Dispatch Interface
STDMETHODIMP CIfadesktopCtrl::XIRibbonExtensObj::Invoke (
	DISPID dispidMember,
	REFIID riid,
	LCID lcid,
	WORD wFlags,
	DISPPARAMS FAR* pdispparams,
	VARIANT FAR* pvarResult,
	EXCEPINFO FAR* pexcepinfo,
	UINT FAR* puArgErr)
	METHOD_PROLOGUE(CIfadesktopCtrl, IRibbonExtensObj)
	LPDISPATCH lpRibbonDisp;
	LPDISPATCH pDisp = pThis->GetIDispatch(FALSE);
	ASSERT(pDisp != NULL);
	pDisp->QueryInterface(IID_IRibbonDisp, (LPVOID FAR *)lpRibbonDisp);
	ASSERT(lpRibbonDisp != NULL);
	return lpRibbonDisp->Invoke(dispidMember, riid, lcid, wFlags, pdispparams,
		pvarResult,pexcepinfo, puArgErr);

 |	IRibbonExtensibility Implementation
STDMETHODIMP CIfadesktopCtrl::XIRibbonExtensObj::GetCustomUI(BSTR RibbonID, BSTR *RibbonXml)
	if (!RibbonXml)
		return E_POINTER;
	*RibbonXml = SysAllocString(
		L"<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\">"
		L" <ribbon>"
		L" <tabs>"
		L" <tab id=\"CustomTab\""
		L" label=\"Custom Tab\">"
		L" <group id=\"CustomGroup\""
		L" label=\"Custom Group\">"
		L" <button id=\"CustomButton\""
		L" imageMso=\"HappyFace\""
		L" size=\"large\""
		L" label=\"Save to the DBMS\""
		L" onAction=\"MySaveToDBMS\"/>"
		L" </group>"
		L" </tab>"
		L" </tabs>"
		L" </ribbon>"

	return (*RibbonXml ? S_OK : E_OUTOFMEMORY);

// End IRibbonExtensibility

Lastly, I will say that I tried using the ATL example in its own CRibbonDisp class (with the appropriate coclass added to the ODL) which included adding ATL support to the ActiveX Control in the process, and had the menu showing up in Word/Excel and it captured the necessary event, but only from within that MySaveToDBMS method - I could not call into any of the legacy ActiveX Control's methods from this class. I'd be willing to go back to that route, but I need to know how to delegate the call to MySaveToDBMS to the ActiveX Control's interface. A simple QI for it from the CRibbonDisp class failed.  All I was able to do was display a message box like all the examples.  When I tried to make calls to other CIfaDesktopCtrl methods, the compiler tells me they are undefined.  I assume this is due to the nested classes.  Maybe I am not inheriting correctly?

I am wondering if I somehow got caught up with the wrong dispatch pointers, but really am not sure where.

Any help or suggestions would be really appreciated.



Good news for all you old dogs who are disinclined to learn a lot of new Office 2007 tricks: Addintools is offering Classic Menu for Office 2007. This add-on re-creates the Office 2003 menus, adapted to present Office 2007 commands — for instance, the add-on's View menu for Word contains 2007's Draft and Full Screen Reading commands instead of the old Normal and Reading Layout commands.

The implementation is pretty clever: Classic Menu places a Menus tab on the Office 2007 Ribbon. You can select the tab to display the Office 2003 menu bar, along with the Standard and Formatting toolbar:

Classic Menu 2007

Click any of the regular Office 2007 tabs, and the Office 2003 elements disappear.
If you're rabidly anti-Ribbon, you can take things even further. Classic Menu provides an All item on the Office 2003 menu bar. Just right-click on All, choose Add To Quick Access Toolbar, and then minimize the Ribbon. A little green button on the Quick Access Toolbar will drop down the Office 2003 menu bar:

Classic Menu 2007

You can follow a similar procedure to add the toolbars to the Quick Access Toolbar. Another little green button will appear, and you can use it to turn on the toolbar display.
Addintools offers a free 15-day trial of the Office 2007 Classic Menu add-on (2.6 Mb). If you decide to purchase the product, you can choose from individual add-ons for Word, Excel, and PowerPoint ($15) or get all three in the Office 2007 Classic Menu package ($29.95).

Thanks to the folks at Office Watch for the heads-up on this product in their latest newsletter.


Hi i create a  print view brower enabled form in Infopath 2007 with header and footer. In Infopath works fine. Margin was ok, header and footter to. But then i try to print this browser the margin, header and footer it changes to default setting of browser ? I try also create a print button in form with VS 2008 code, but method :

this.print(); not working.

It is possible to print the "print view" in browser as the same like in Infopath 2007? Does anyone have the code how to create a print button in C# on browser enabled form?


I have a grid view with each row as a link button. When I click on the row, some data parsing process takes place (about a 15 sec process). The grid refreshes itself at a regular interval. I want to disable the link when it is clicked once, so that the user gets to know that row has been processed already and does not click it again, until the grid refreshes itself and the row disappears.
I am copying my gridview code below. Please give me some idea on how to disable the link button on that row as soon as it is clicked.

Thank You.

 <td rowspan = "4" valign = "top" >
            <asp:Label ID="gvOrdersQueueLabel" runat="server" ></asp:Label><br />
             <asp:UpdatePanel runat="server" ID="updatePane1">
                    <asp:GridView ID="gvOrdersQueue" runat="server" OnRowCommand = "ParseOrderMessage" EmptyDataText="No Cases Found"  BorderStyle = "Double" 
                    AlternatingRowStyle-BackColor="Beige" EnableViewState="false" AutoGenerateColumns="False"  HeaderStyle-Height = "20" RowStyle-Height = "20" AllowPaging ="true" 
                         PageSize = "20" OnPageIndexChanging="gridView_PageIndexChanging" PagerSettings-Mode = "NumericFirstLast"  Font-Size = "Small">
                <asp:TemplateField HeaderText="Message ID" ItemStyle-Wrap = "false">
                    <asp:Label ID="LblMsgID" runat="server" Text='<%# Eval("MessageID") %>' visible="false"></asp:Label>  
                    <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument ='<%# Eval("MessageID") +"|"+ Eval("FileName")%>' CommandName = "WriteORM" ><%# Eval("MessageID") %></asp:LinkButton>
                <asp:TemplateField HeaderText="Date Time" ItemStyle-Wrap = "false">
                    <asp:LinkButton ID="LinkButton2" runat="server" CommandArgument ='<%# Eval("MessageID") +"|"+ Eval("FileName")%>' CommandName = "WriteORM" ><%# Eval("MessageDateTime") %></asp:LinkButton>
                <asp:TemplateField HeaderText="File Name" ItemStyle-Wrap = "false">
                    <asp:LinkButton ID="LinkButton3" runat="server" CommandArgument ='<%# Eval("MessageID") +"|"+ Eval("FileName")%>' CommandName = "WriteORM" ><%# Eval("FileName") %></asp:LinkButton>
                    <asp:Timer ID="Timer1" runat="server" OnTick="Timer_Tick"> </asp:Timer>


Hello experts,

I have an Outlook 2007 add-in developed in VS 2008. Very often the add-in gets disabled for unknown reason and the user has to turn it back ON each time from the trust center.

I have found some articles on net that state similar to the following:


"There are two types of disabling that Microsoft Office applications use for add-ins: hard disabling and soft disabling.

Hard Disabling

Hard disabling can occur when an add-in causes the application to close unexpectedly. It might also occur on your development computer if you stop the debugger while the Startup event handler in your add-in is executing. When an add-in is hard disabled, it appears in the Disabled Items list in the application.

If an Office application hard disables an add-in created by using Office development tools in Visual Studio, the application disables only the add-in that caused the failure. Other add-ins created by using Office development tools in Visual Studio for that Office application will continue to load.

Soft Disabling

Soft disabling can occur when an add-in produces an error that does not cause the application to unexpectedly close. For example, an application might soft disable an add-in if it throws an unhandled exception while the Startup event handler is executing. When an add-in is soft disabled, it appears in the Inactive Application Add-ins list in the application, and the application changes the value of the LoadBehavior registry entry for the add-in to indicate that it is unloaded. For more information about the LoadBehavior registry entry, see Registry Entries for Application-Level Add-Ins."


But I have checked my code properly and did not find any piece of code outside try..Catch block.

Now what I am trying to make sure is that the add-in never gets disabled.

Is there any option to tell office application not to disable the add-in in any case, even if an un-handled error occurs/closes unexpectedly?

Thanks in advance...

-Jahedur Rahman



When i try to edit a pwa view in PS2007 sp2 June CU, the add, remove and remove all buttons under the Table and Fields section are disabled. It will only work if I use PWA from the app/web server. 

I used the getsitelock cmd for stsadm.exe and it returned with none.  I really dont know what else to check for here, any help is creatly appreciated.




can any one guide me how to add menu in Office orb, Send menu.

my Addin is written in VC++/ATL.





we have created custom entity "abc"

the entity has one to many relation with opportunity.

the lookup field on the opportunity entity name is abcid.

I have the following requirement

- user should be able to create new record of type abc from the abc entity only

- user should not be able to use the new button in the lookup view for the custom entity abc. ie. when user click onth abcid lookup field in opportunit user should not be allowed click on new button and create new abc record.


my question is how do I disable or hide the new button in the lookup window without preventing user from creating new record of abc fromt he entity.



I have a compartment shape in my DSL and I want user to add Item into it based on the flag. User can right click on the shape and Add an Item by using Context Menu. Hence, I want to enable/disable this Context menu based on a flag that held as part of domain object. http://social.msdn.microsoft.com/Forums/en/dslvsarchx/thread/854b5fbd-7ca7-40eb-9558-e6abb1049d82  suggests to remove the Element merge directive corresponding to your child class in under the "Element Merge Directives" of your parent domain class in the "Domain Classes". But I need that context menu and want it enable and diable dynamically.


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure