What is the C# equivalent of this Excel VBA code for Shapes?
- by code4life
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!