I'm trying to rotate a line shape (created with the Shapes.AddLine method) about a point.
I've found an example authored by Chip Pearson - a clock - that does this nicely. It uses the following code to move the second hand:
Private Sub SetSecondHand(Seconds As Single)Dim Theta As Single ' clockwise angle from verticalDim NewX As SingleDim NewY As SingleDim LS as ShapeTheta = (Seconds / 60) * TwoPINewX = cCenterX + (cLenSecond * Sin(Theta))NewY = cCenterY - (cLenSecond * Cos(Theta))LS.Nodes.SetPosition 2, NewX, NewY
this indeed works with polylines.
In order for the text fields to work, i updated the initialising code a little. Clock.xls
0
dsimcoxAuthor Commented:
A little more investigation - the shape Chip created (in an older version of Excel) with the Shape.AddLine method has no nodes in the newer versions of Excel. LS.Nodes.Count yields 0. If I create a free-form shape, it has a positive node count. Apparently the lines created with Shape.AddLine are different and node-less.
I've worked with the rotation property - but it rotates about the center point of the line. I want to rotate the line about the end point.
I think the nodes property is still accessible. If you draw a free-form line and check for nodes in the immediate window, it returns the correct answer - but not for a autoshape.
dsimcox, have you tried the updated version of the clock.xls file ?
it uses polylines instead of lines. With polylines (which do have node objects accessible) the clock lines indeed can be pointed 'in the right direction' using macro code.
The version that I uploaded works at my workplace, using excel 2007.
Can you verify that it also works at your location ?
0
dsimcoxAuthor Commented:
I'd like to try the newer version of clocks.xls but I don't know where to find it. Can you post a link please?
In order for the text fields to work, i updated the initialising code a little.
Clock.xls