views:

489

answers:

1

hi, 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  A: 

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&amp;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.

Dennis Palmer
thanks Dennis, how do i provide action for my button? i mean where... also how will i be able to insert an image on that previewed sheet?thanks a lot in advance!
hi Dennis, is it possible to insert image with that button on that previewed sheet...? thanks in advance!
You really need to go to that MSDN getting started article. Come back here and ask questions if you don't understand something, but it's all in there.
Dennis Palmer