Solved

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

Posted on 2013-02-05
1
777 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

732 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