问题
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