c# excel 2007 print preview ribbon

眉间皱痕 提交于 2019-12-13 03:47:20

问题


is it possible from c# to add some groups, buttons,... to excel-2007's print preview ribbon... why? i wanted to put some images on that ribbon so that user by selecting the image will be able to put it on a sheet (where ever on that sheet by dragging it) and print it with that sheet... many thanks!


回答1:


You do this the same way you add a group to any existing excel ribbon tab.

Create a VSTO add-in project and add a Ribbon XML class.

Inside the ribbon.xml file, this will give you a group with one button on the print preview tab:

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
  <ribbon>
    <tabs>
      <tab idMso="TabPrintPreview">
        <group id="MyGroup"
               label="My Group">
          <button id="Test" label="Test"/>
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

In order to find the names of all the built in tabs, groups and controls, check out this download

http://www.microsoft.com/downloads/details.aspx?familyid=4329D9E9-4D11-46A5-898D-23E4F331E9AE&displaylang=en

That will tell you what id's to use for the idMso (Microsoft Office id) attributes.

Here's a great place to get started:

http://msdn.microsoft.com/en-us/library/aa338202.aspx

Check out the Using Callbacks section for info on how to handle button clicks.



来源:https://stackoverflow.com/questions/1160905/c-sharp-excel-2007-print-preview-ribbon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!