I'm attempting to insert a shape at a specific cell, say (5,5) for instance. I am able to get the shape into excel, but can't figure out how to put it in (5,5). After research, I know that shapes sit on top of cells in worksheets. I have also learned that .Range
could be helpful here.
I'm just uncertain of how to put these pieces of the puzzle together to make my shape go to (5,5).
xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeIsoscelesTriangle, 17, 0, 15, 13)
Also, am a beginner to vb.net so if you could dumb everything down i'd really appreciate it!
EDIT:
Tried this code.. but it put the number 7
in (5,5) instead of the shape.
Dim aNew As MsoAutoShapeType = MsoAutoShapeType.msoShapeIsoscelesTriangle
xlWorkSheet.Cells(5, 5) = anew
Also tried:
xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeIsoscelesTriangle, xlWorkSheet.Range(xlWorkSheet.Cells(5, 5)).Left, xlWorkSheet.Range(xlWorkSheet.Cells(5, 5)).Top, 15, 13)
but received an error of
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred
EDIT: Code that worked...
xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, (xlWorkSheet.Cells(3, 5)).Left, (xlWorkSheet.Cells(3, 5)).Top, 25, 14)