Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-02-05
1
Medium Priority
?
794 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

609 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