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
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