Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

759 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now