By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,452 Members | 974 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,452 IT Pros & Developers. It's quick & easy.

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

P: n/a
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:
Expand|Select|Wrap|Line Numbers
  1.                 xlApp.Visible = True
  2.                 If DGShapes.Item(3, intCtr).Value = "Line" Then
  3.                     P1.X = (CDbl(DGShapes.Item(4, intCtr).Value)) / 1.5
  4.                     P1.Y = (CDbl(DGShapes.Item(5, intCtr).Value)) / 1.5
  5.                     P2.X = (CDbl(DGShapes.Item(6, intCtr).Value)) / 1.5
  6.                     P2.Y = (CDbl(DGShapes.Item(7, intCtr).Value)) / 1.5
  7.                     dblShape_Length = Math.Sqrt(((P1.X - P2.X) * (P1.X - P2.X)) + ((P1.Y - P2.Y) * (P1.Y - P2.Y)))
  8.                     s_Width = dblShape_Length
  9.                     s_Left = P1.X
  10.                     s_Top = P1.Y
  11.                     s_Height = 0
  12.                     dblSlope = (P2.Y - P1.Y) / (P2.X - P1.X)
  13.                     dbl_Shape_Angle = Math.Atan(dblSlope) * 180 / Math.PI
  14.                     shape_001 = xlWorkSheet.Shapes.AddShape(Core.MsoLineStyle.msoLineSingle, s_Left, s_Top, s_Width, s_Height)
  15.                     shape_001.Line.ForeColor.RGB = RGB(250, 0, 0)
  16.                     shape_001.Line.Weight = 3
  17.                     shape_001.Rotation = dbl_Shape_Angle
  18.  
  19.  
  20.                     shape_001.Left = ? 'These are my probs
  21.                     shape_001.Top = ?
  22.  
  23.                 End If
  24.  
  25.  
PS: DGShapes is a datagridview. I'm working on multiple shapes per entry... INTCTR is my counter.
Nov 15 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.