0

I want to create a ContextMenuListRange in VSTO where I have already created one more xml for ContextMenuCell. If I add the List Range in one more tag, the Ribbon is saying "Object Reference not set to instance of an object. Here is the xml tag

<contextMenus>
<contextMenu idMso="ContextMenuCell">
  <menu id="MySubMenu" label="Visualization">
    <button id="contextBtn2" getEnabled="GetEnabled" getLabel="GetLabel" image="2Image" onAction="Part2Vis_Click"/>
    <button id="contextBtn3" getEnabled="GetEnabled" getLabel="GetLabel" image="3Image" onAction="Part3Vis_Click"/>
    <button id="contextBtn3Mod" getEnabled="GetEnabled" getLabel="GetLabel" image="3Module" onAction="Module3Vis_Click"/>
    <button id="contextBtnAdv" getLabel="GetLabel" onAction="BtnAdvClick" image="advImage"/>
    <button id="contextBtnOption" getLabel="GetLabel" onAction="BtnOptionClick" image="Settings"/>
    <button id="contextBtnHelpPage" getLabel="GetLabel" onAction="BtnHelpPageClick"  image="Help"/>
  </menu>     
</contextMenu>
</contextMenus> 
<contextMenus>
<contextMenu idMso="ContextMenuListRange">
  <menu id="MyContextNew" label="Visualization">
    <button id="contextBtn2d" getEnabled="GetEnabled" getLabel="GetLabel" image="2dImage" onAction="Part2DVis_Click"/>
    <button id="contextBtn3d" getEnabled="GetEnabled" getLabel="GetLabel" image="3dImage" onAction="Part3DVis_Click"/>
    <button id="contextBtn3dMod" getEnabled="GetEnabled" getLabel="GetLabel" image="3DModule" onAction="Module3DVis_Click"/>
    <button id="contextBtnAdv" getLabel="GetLabel" onAction="BtnAdvClick" image="advImage"/>
    <button id="contextBtnOption" getLabel="GetLabel" onAction="BtnOptionClick" image="Settings"/>
    <button id="contextBtnHelpPage" getLabel="GetLabel" onAction="BtnHelpPageClick"  image="Help"/>
  </menu>     
</contextMenu>

roopini n
  • 503
  • 2
  • 7
  • 29

2 Answers2

0

enclose everything inside contextMenus

<contextMenus>
<contextMenu idMso="ContextMenuCell">
  <menu id="MySubMenu" label="Visualization">
    <button id="contextBtn2" getEnabled="GetEnabled" getLabel="GetLabel" image="2Image" onAction="Part2Vis_Click"/>
    <button id="contextBtn3" getEnabled="GetEnabled" getLabel="GetLabel" image="3Image" onAction="Part3Vis_Click"/>
    <button id="contextBtn3Mod" getEnabled="GetEnabled" getLabel="GetLabel" image="3Module" onAction="Module3Vis_Click"/>
    <button id="contextBtnAdv" getLabel="GetLabel" onAction="BtnAdvClick" image="advImage"/>
    <button id="contextBtnOption" getLabel="GetLabel" onAction="BtnOptionClick" image="Settings"/>
    <button id="contextBtnHelpPage" getLabel="GetLabel" onAction="BtnHelpPageClick"  image="Help"/>
  </menu>     
</contextMenu>

<contextMenu idMso="ContextMenuListRange">
  <menu id="MyContextNew" label="Visualization">
    <button id="contextBtn2d" getEnabled="GetEnabled" getLabel="GetLabel" image="2dImage" onAction="Part2DVis_Click"/>
    <button id="contextBtn3d" getEnabled="GetEnabled" getLabel="GetLabel" image="3dImage" onAction="Part3DVis_Click"/>
    <button id="contextBtn3dMod" getEnabled="GetEnabled" getLabel="GetLabel" image="3DModule" onAction="Module3DVis_Click"/>
    <button id="contextBtnAdv" getLabel="GetLabel" onAction="BtnAdvClick" image="advImage"/>
    <button id="contextBtnOption" getLabel="GetLabel" onAction="BtnOptionClick" image="Settings"/>
    <button id="contextBtnHelpPage" getLabel="GetLabel" onAction="BtnHelpPageClick"  image="Help"/>
  </menu>     
</contextMenu>

</contextMenus> 
Brijesh Mishra
  • 2,738
  • 1
  • 21
  • 36
  • No its not working. :( Actually I am trying to import the data from a text file.. and when I right click on the data my addin is not seen. So I read that using ContextMenuListRange would help me because the data imported are represented as table in Excel. – roopini n Sep 23 '14 at 06:32
0

Avoid duplicating button id names… I changed and Works fine

<contextMenus>
<contextMenu idMso="ContextMenuCell">
    <menu id="MySubMenu" label="Visualization">
        <button id="contextBtn2" getEnabled="GetEnabled" getLabel="GetLabel" image="2Image" onAction="Part2Vis_Click"/>
        <button id="contextBtn3" getEnabled="GetEnabled" getLabel="GetLabel" image="3Image" onAction="Part3Vis_Click"/>
        <button id="contextBtn3Mod" getEnabled="GetEnabled" getLabel="GetLabel" image="3Module" onAction="Module3Vis_Click"/>
        <button id="contextBtnAdv" getLabel="GetLabel" onAction="BtnAdvClick" image="advImage"/>
        <button id="contextBtnOption" getLabel="GetLabel" onAction="BtnOptionClick" image="Settings"/>
        <button id="contextBtnHelpPage" getLabel="GetLabel" onAction="BtnHelpPageClick"  image="Help"/>
  </menu>     
</contextMenu>

<contextMenu idMso="ContextMenuListRange">
  <menu id="MyContextNew" label="Visualization">
    <button id="contextBtn2d" getEnabled="GetEnabled" getLabel="GetLabel" image="2dImage" onAction="Part2DVis_Click"/>
    <button id="contextBtn3d" getEnabled="GetEnabled" getLabel="GetLabel" image="3dImage" onAction="Part3DVis_Click"/>
    <button id="contextBtn3dModX" getEnabled="GetEnabled" getLabel="GetLabel" image="3DModule" onAction="Module3DVis_Click"/>
    <button id="contextBtnAdvX" getLabel="GetLabel" onAction="BtnAdvClick" image="advImage"/>
    <button id="contextBtnOptionX" getLabel="GetLabel" onAction="BtnOptionClick" image="Settings"/>
    <button id="contextBtnHelpPageX" getLabel="GetLabel" onAction="BtnHelpPageClick"  image="Help"/>
  </menu>     
</contextMenu>

</contextMenus>