Controlling horizontal anchor points in PowerPoint 2010

O

Oliver Bock

If you use add a TextFrame to a PowerPoint slide and then enter new
text, the frame will expand to the right. However if you rotate it and
then add extra text it will expand equally to both left and right. That
is, the horizontal anchor point moves to the centre when text is rotated.

PowerPoint 2007 also exhibitted this behaviour in the GUI, but not when
I added objects using C# + COM interop. The code below works on
PowerPoint 2000, 2002, 2003 and 2007, but not on 2010.

PowerPoint.Shape text =
shapes.AddLabel(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0,
0, 0);
text.TextFrame.HorizontalAnchor = MsoHorizontalAnchor.msoAnchorNone;
text.TextFrame.TextRange.ParagraphFormat.Alignment =
PpParagraphAlignment.ppAlignLeft;
text.TextFrame.VerticalAnchor = MsoVerticalAnchor.msoAnchorMiddle;
text.TextFrame.TextRange.Text = s;
text.Left = (float)x;
text.Top = (float)y;
double degrees = angle * 180.0 / Math.PI;
text.Rotation = (float)degrees;

In PowerPoint 2010 the position of the new label is wrong because it
rotates about its centre. I am trying to position a label on the
perimeter of a circle (at x,y) and I want the label text to grow away
from this point.

Is there any way to force the horizontal anchor point to the left side
with rotated text?


Oliver
 
C

Colbert Zhou [MSFT]

Hello Oliver,

The issue is caused from the shape size and autofit mode. You can try the
following codes to achieve what you want in PowerPoint 2010,

Sub Test()
Dim text As Shape
Set text =
Application.ActivePresentation.Slides(1).Shapes.AddLabel(msoTextOrientationH
orizontal, 0, 0, 0, 0)
text.TextFrame.HorizontalAnchor = msoAnchorNone
text.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignLeft
text.TextFrame.VerticalAnchor = msoAnchorMiddle
text.TextFrame.TextRange.text = "sssssssssss"
text.Left = 30
text.Top = 30
Dim degrees As Double
degrees = 45 * 180 / 3.1415926
text.Height = 0
text.Width = 0
text.TextFrame.AutoSize = ppAutoSizeNone
text.Rotation = degrees
End Sub


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top