What is the C# equivalent of this Excel VBA code for Shapes?

Posted by code4life on Stack Overflow See other posts from Stack Overflow or by code4life
Published on 2010-05-18T19:52:22Z Indexed on 2010/05/18 20:50 UTC
Read the original article Hit count: 569

Filed under:
|
|
|

This is the VBA code for an Excel template, which I'm trying to convert to C# in a VSTO project I'm working on. By the way, it's a VSTO add-in:

Dim addedShapes() As Variant
ReDim addedShapes(1)
addedShapes(1) = aBracket.Name

ReDim Preserve addedShapes(UBound(addedShapes) + 1)
addedShapes(UBound(addedShapes)) = "unique2"

Set tmpShape = Me.Shapes.Range(addedShapes).Group

At this point, I'm stumped by the addedShapes(), not sure what this is all about.

Update: Matti mentioned that addedShapes() represents a variant array in VBA. So now I'm wondering what the contents of addedShapes() should be. Would this be the correct way to call the Shapes.Range() call in C#?

List<string> addedShapes = new List<string>();
...
Shape tmpShape = worksheet.Shapes.get_Range
  (addedShapes.Cast<object>().ToArray()).Group();

I'd appreciate anyone who's worked with VBA and C# willing to make a comment on my question & problem!

© Stack Overflow or respective owner

Related posts about vsto

Related posts about vba-to-c#