title: Microsoft Word Add-In - Add to Contextual Menu
body: <p>I've built an Add-In for Word and would now like to add an option to call a function from it when a user highlights a word and right clicks on it. I've found documentation <a href="https://docs.microsoft.com/en-us/office/dev/add-ins/develop/create-addin-commands#step-7-add-the-resources-element" rel="nofollow noreferrer">here</a> on how to modify the manifest.xml file but it doesn't seem to show a full example of how to add to the contextual menu, only how to add buttons and drop down menus.</p>
  
  <p>The documentation also points me to a <a href="https://github.com/OfficeDev/Office-Add-in-Commands-Samples/" rel="nofollow noreferrer">github</a> page show examples but again lacks one for contextual menus. It also points to <a href="https://channel9.msdn.com/events/Build/2016/P551" rel="nofollow noreferrer">this</a> video which seems to show what I want at about 1:20 but also doesn't show how to implement it.</p>
  
  <p>So far I have this (added below the <code>&lt;FunctionFile&gt;</code>):</p>
  
  <pre><code>&lt;ExtensionPoint xsi:type="ContextMenu"&gt;
    &lt;OfficeMenu id="ContextMenuText"&gt;
      &lt;Control xsi:type="Menu" id="TestMenu"&gt;
        &lt;Label resid="ContextMenuLabel" /&gt;
        &lt;Supertip&gt;
            &lt;Title resid="ContextualMenuTitle" /&gt;
            &lt;Description resid="ContextualMenuTitleDesc" /&gt;
        &lt;/Supertip&gt;
      &lt;/Control&gt;         
    &lt;/OfficeMenu&gt;
  &lt;/ExtensionPoint&gt;
  </code></pre>
  
  <p>When I try and validate the manifest file with <a href="https://github.com/OfficeDev/office-addin-validator" rel="nofollow noreferrer">this tool</a> it tells me that I'm missing an <code>Icon</code> element, but I don't need an image for a context menu?</p>
  
  <p>Is what I'm trying to do possible and if so could someone point me to an example?</p>
  
  <hr>
  
  <h2>Edit:</h2>
  
  <p>I've updated my code to reflect what @Mavi Domates  wrote</p>
  
  <pre><code>&lt;ExtensionPoint xsi:type="ContextMenu"&gt;
    &lt;OfficeMenu id="ContextMenuText"&gt;
      &lt;Control xsi:type="Button" id="openSearchButton"&gt;
        &lt;Label resid="openSearchButtonLabel" /&gt;
        &lt;Supertip&gt;
          &lt;Title resid="openSearchButtonTitle" /&gt;
          &lt;Description resid="openSearchButtonDescription" /&gt;
        &lt;/Supertip&gt;
        &lt;Icon&gt;
          &lt;bt:Image size="16" resid="Contoso.tpicon_16x16" /&gt;
          &lt;bt:Image size="32" resid="Contoso.tpicon_32x32" /&gt;
          &lt;bt:Image size="80" resid="Contoso.tpicon_80x80" /&gt;
        &lt;/Icon&gt;
        &lt;Action xsi:type="ExecuteFunction"&gt;
          &lt;FunctionName&gt;getData&lt;/FunctionName&gt;
        &lt;/Action&gt;
      &lt;/Control&gt;
    &lt;/OfficeMenu&gt;
  &lt;/ExtensionPoint&gt;
  </code></pre>
  
  <p>When I add this code (right below the default <code>&lt;ExtensionPoint xsi:type="PrimaryCommandSurface"&gt;</code> My add-in no longer shows up in the "My Add-ins" menu. I downloaded Microsoft's <a href="https://github.com/OfficeDev/office-addin-validator" rel="nofollow noreferrer">manifest validator</a> and it tells me my manifest is fine.</p>
  
  <p>I've narrowed it down to the <code>Control</code> node causing the problem. If I just add:</p>
  
  <pre><code>&lt;ExtensionPoint xsi:type="ContextMenu"&gt;
    &lt;OfficeMenu id="ContextMenuText"&gt;
    &lt;/OfficeMenu&gt;
  &lt;/ExtensionPoint&gt;
  </code></pre>
  
  <p>my add-in still shows in the menu. I've also added the relevant strings in my resources under <code>&lt;bt:ShortStrings&gt;</code>:</p>
  
  <pre><code>&lt;bt:String id="openSearchButtonLabel" DefaultValue="Check it out!" /&gt;
  &lt;bt:String id="openSearchButtonTitle" DefaultValue="Hover over me" /&gt;
  &lt;bt:String id="openSearchButtonDescription" DefaultValue="For more info go here" /&gt;
  </code></pre>
  
  <p>My code seems to be exactly the same as the documentation. I'm not sure where to go from here. I'm on a mac if that changes things.</p>