Solved

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

Posted on 2013-02-05
1
785 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

Technology Partners: 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…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

691 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