How can I reposition an AutoShape from Excel using vb .net 2005?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • everizza

    #1

    How can I reposition an AutoShape from Excel using vb .net 2005?

    The problem goes like this. Initially, when I make a line (autoshape) from vb .net to excel everything is well, but when a line requires a rotation (thru a slope compuation), the line's starting postion is also moved. When I try to look at the the shape's LEFT property, the value is still the same as it was been equated (still the same as P1.X's value). Is there anyway I could get the new value of the LEFT property so I can move my shape to the right coordinate?

    A series of line from my code are as follows:
    Code:
                    xlApp.Visible = True
                    If DGShapes.Item(3, intCtr).Value = "Line" Then
                        P1.X = (CDbl(DGShapes.Item(4, intCtr).Value)) / 1.5
                        P1.Y = (CDbl(DGShapes.Item(5, intCtr).Value)) / 1.5
                        P2.X = (CDbl(DGShapes.Item(6, intCtr).Value)) / 1.5
                        P2.Y = (CDbl(DGShapes.Item(7, intCtr).Value)) / 1.5
                        dblShape_Length = Math.Sqrt(((P1.X - P2.X) * (P1.X - P2.X)) + ((P1.Y - P2.Y) * (P1.Y - P2.Y)))
                        s_Width = dblShape_Length
                        s_Left = P1.X
                        s_Top = P1.Y
                        s_Height = 0
                        dblSlope = (P2.Y - P1.Y) / (P2.X - P1.X)
                        dbl_Shape_Angle = Math.Atan(dblSlope) * 180 / Math.PI
                        shape_001 = xlWorkSheet.Shapes.AddShape(Core.MsoLineStyle.msoLineSingle, s_Left, s_Top, s_Width, s_Height)
                        shape_001.Line.ForeColor.RGB = RGB(250, 0, 0)
                        shape_001.Line.Weight = 3
                        shape_001.Rotation = dbl_Shape_Angle
    
                    
                        shape_001.Left = ? 'These are my probs
                        shape_001.Top = ?
                       
                    End If
    PS: DGShapes is a datagridview. I'm working on multiple shapes per entry... INTCTR is my counter.
Working...