From: Omatase on
I have this code:

object offset = 1;
object unit = Word.WdUnits.wdLine;

mergeFields.ShapeRange.Anchor.LockAnchor = 0;
mergeFields.ShapeRange.Anchor.Move(ref unit, ref offset);

The anchor lock goes away so I know I have a reference to the correct
anchor object but I can't seem to move it anywhere.

Now granted the above code is not VBA but if someone can show me how
to do what I want in VBA I can translate it to C#. I just couldn't
find a forum that was for word AND C#.

Please help

Thanks

From: Russ on
There doesn't appear to be a move method for an anchor. You can drag and
drop it, but I can't record a drag and drop.
Below are some pieces of information that might help.

This example repositions the selected shape object.
With Selection.ShapeRange
.Left = InchesToPoints(0.6)
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.Top = InchesToPoints(1)
.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
End With

This example creates a new document, adds a shape to it, and then locks the
shape's anchor.
Set myDoc = Documents.Add
Set myShape = myDoc.Shapes.AddShape(msoShapeBalloon, 0, 0, 140, 70)
myShape.LockAnchor = True
ActiveWindow.View.ShowObjectAnchors = True

Anchor Property Example
This example selects the paragraph that the first shape in the active
document is anchored to.
ActiveDocument.Shapes(1).Anchor.Paragraphs(1).Range.Select

Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 108#
Selection.ShapeRange.Width = 144#
Selection.ShapeRange.Rotation = 0#
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionColumn
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionParagraph
Selection.ShapeRange.Left = InchesToPoints(2.43)
Selection.ShapeRange.Top = InchesToPoints(-0.25)
Selection.ShapeRange.LockAnchor = True
Selection.ShapeRange.WrapFormat.AllowOverlap = True
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.ZOrder ZOrderCmd:=4

> I have this code:
>
> object offset = 1;
> object unit = Word.WdUnits.wdLine;
>
> mergeFields.ShapeRange.Anchor.LockAnchor = 0;
> mergeFields.ShapeRange.Anchor.Move(ref unit, ref offset);
>
> The anchor lock goes away so I know I have a reference to the correct
> anchor object but I can't seem to move it anywhere.
>
> Now granted the above code is not VBA but if someone can show me how
> to do what I want in VBA I can translate it to C#. I just couldn't
> find a forum that was for word AND C#.
>
> Please help
>
> Thanks
>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

From: Omatase on
Thanks for the help but I have to be able to move the anchors. I found
a way to get word to auto move the anchor in some cases and that is by
calling IncrementTop(1f); on the shape. It doesn't always work
programmatically though even though it works consistently in the UI.

Any help is much appreciated.

From: Russ on
This is from Word VBA Help:
****Quote
A shape is always attached to an anchoring range. You can position the shape
anywhere on the page that contains the anchor.
****UnQuote

The anchor is only dependable apparently for determining which page a shape
will stick to.

If you want a more dependable fix to certain text, then use an inline shape,
which acts like Character.


> Thanks for the help but I have to be able to move the anchors. I found
> a way to get word to auto move the anchor in some cases and that is by
> calling IncrementTop(1f); on the shape. It doesn't always work
> programmatically though even though it works consistently in the UI.
>
> Any help is much appreciated.
>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

From: Omatase on
The specific problem I'm having is that I am trying to copy some text
into a table. When I do, if there is a shape that has an anchor
attached to the text, then the shape moves inside the table with the
anchor. In Word 2003 or better I can turn the Layout in table cell
property off on the shape, but in word 2000 (which is what I have to
support) there is no such option. Moving the anchor fixes the problem,
but I can't get it to move.

Thanks for your continued help.