Solved

Convert VBC code to C#

Posted on 2013-02-04
4
218 Views
Last Modified: 2013-03-04
Hi
I have a small section of VBA code which I need to convert/rewrite in C#.
Basically the code specifies the count, name and location of images which are to be used in a gallery on a custom Excel Ribbon:

Sub getBSCGalleryItemImages(control As IRibbonControl, index As Integer, ByRef image)
    Set image = LoadPicture("//images/report_snapshot_" & index + 1 & ".jpg")
End Sub
Sub getBSCGalleryItemCount(control As IRibbonControl, ByRef count)
        count = 3
End Sub

Open in new window


Thanks for the help

Fergal
0
Comment
Question by:fjkilken
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 38855182
It would be something like the following:
void getBSCGalleryItemImages(IRibbonControl control,int Index, ref image) {

    image = LoadPicture("//images/report_snapshot_" + int.parse(index + 1) + ".jpg");

}

void getBSCGalleryItemCount(IRibbonControl control, ref count) {

        count = 3;

}

Open in new window


Per your code I didn't know what type variable count was or Image, so those may have to be added.
0
 

Author Comment

by:fjkilken
ID: 38856096
doesn't look like that will work - "LoadPicture" method is not recognised
0
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 38856194
OK.
You will need a

using System.Drawing;

at the top of the module in C#


String path="//images/report_snapshot_" + int.parse(index + 1) + ".jpg";
Image image1 = Image.FromFile(path);

Image.FromFile()
can load an image from a file.
0
 

Author Comment

by:fjkilken
ID: 38856245
thanks,
let me take a look at incorporating that tomorrow
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

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…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

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

26 Experts available now in Live!

Get 1:1 Help Now