I have scribble line object in my Ms Word document.

Shape.Type = msoFreeform

Now I want to get position of the controls points and change it slightly. How can I get the controls points' position in the first place.

I noticed that

Shape.ShapeNodes.SetPosition ( index, x, y)

helped me to set position of each node. However, no ShapeNodes.GetPosition function exists.

Each ShapeNode has a Points property, but the Points property does not return me position of the node no matter what I tried.

Can anybody (from Microsoft maybe) tell how to use the Office SDK to get the positions of the control Points of a scribble shape whose type is msoFreeform

If this can not be done in Word, can that be done in PowerPoint and Excel instead

Re: How to Get Position of Scribble line's Points?


Code Block

t = ActiveDocument.Shapes(1).Top
l = ActiveDocument.Shapes(1).Left

Code Block

ActiveDocument.Shapes(1).Top = ActiveDocument.Shapes(1).Top + 10
ActiveDocument.Shapes(1).Left = ActiveDocument.Shapes(1).Left + 10

Re: How to Get Position of Scribble line's Points?


Thanks for your replying. bi-lya. But that does not solve the problem.

My problem is a Scribble line would have a sequence of control points. For example, if my scribble line has 10 control points and I want to know the position of the 5th control point in my VBA program and modify that point only, would you have any idea on how to get the point's current position

Re: How to Get Position of Scribble line's Points?

Andy Pope


This will list the nodes of the first shape in your document.

Notice I declared objNode as Object. This is because in Word 2007 I was getting a Type mismatch when using ShapeNode type.
And as you mentioned use the SetPosition method to change a node.

Sub x()
Dim shpTemp As Shape
Dim lngIndex As Long
Dim objNode As Object ' ShapeNode
Dim vntPointArray As Variant
Dim vntX As Variant
Dim vntY As Variant

Set shpTemp = ActiveDocument.Shapes(1)

Debug.Print shpTemp.Nodes.Count
For Each objNode In shpTemp.Nodes
lngIndex = lngIndex + 1
vntPointArray = objNode.Points
vntX = vntPointArray(1, 1)
vntY = vntPointArray(1, 2)

Debug.Print "Node "; lngIndex, "X="; vntX, "Y="; vntY
End Sub

Re: How to Get Position of Scribble line's Points?


Thank you. Andy. Your code does solve my earlier problem.

I don't have the Type-Mismatch error any more.