Solved

Need method to source image files (C# Ribbon for Excel)

Posted on 2013-02-05
1
762 Views
Last Modified: 2013-02-08
Hi
I have an Excel Ribbon project built in C# Visual Studio.
Most of the images I am using are built-in ones (I use imageMso values) but there are some custom images I want to use.
I have already imported the images into the Resources folder, and have been successfully able to render one of them (as the image for a button)

Problem is that I want to render more of these custom images, but my callback (loadImage="GetImage" on the customUI xmlns line) only references a single image, so I'd like the callback to reference multiple images.

The "GetImage" code callback is shown below:
public stdole.IPictureDisp GetImage(string imageNameexpere)
{
return PictureConverter.ImageToPictureDisp(Properties.Resources.news);
}

Open in new window


From various sources, I've been advised the following:
The <customUI> element's loadImage attribute enables you to specify a callback that can load all images. After you set up this callback procedure, Office calls the callback procedure and passes the string from the image attribute for each control that loads images.
To supply the button's image, Office calls the GetImage function. It passes the parameter "mypic" (as an example) and expects an IPictureDisp object in return. By using this technique, you can write a single callback procedure that returns all the images your customization needs, without having to write each individual control's getImage callback.


As I understand it, what is supposed to happen is that the parameter (eg; "mypic.jpg") is passed to GetImage, and this parameter replaces the default which is in GetImage (which in this case is an image called "news")

Ideally I guess, the GetImage method needs to be modified to accept an input parameter, and this input parameter needs to be the name of the imported image (eg; "mypic"), so that this image reference can be passed in.

Appreciate any help!

Fergal
0
Comment
Question by:fjkilken
1 Comment
 

Accepted Solution

by:
fjkilken earned 0 total points
ID: 38868948
got this sorted per example below:

  public stdole.IPictureDisp GetRibbonImage(string imageName)
                {
                stdole.IPictureDisp returnPic = null;

                switch (imageName)
                    {
                    case "anl_1":
                        returnPic = PictureConverter.ImageToPictureDisp(Properties.Resources.news);
                        break;
                    case "beta_icon":
                        returnPic = PictureConverter.ImageToPictureDisp(Properties.Resources.beta_icon);
                        break;

Open in new window


etc....
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question