none
msoAutoSizeTextToFitShape property not taking effect while in slideshow in PPT2010 RRS feed

  • Question

  • Hi,

    I'm having problems getting the msoAutoSizeTextToFitShape property of a shape to take effect in PowerPoint 2010. I have the following code which runs while a slideshow is in progress. The problem is that the text does not resize to fit the shape until I exit the slideshow. Is there anyway to prompt it to take effect immediately when the shape is added?

            private PowerPoint.Shape AddColoredShape(Color color, string text, float left, float top, float width, float height)
            {
                PowerPoint.Shape shape = this.slide.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRoundedRectangle, left, top, width, height);
    
                int rgbBackground = ColorTranslator.ToOle(color);
                int rgbBorder = ColorTranslator.ToOle(GetBorderColor(color));
                int rgbText = ColorTranslator.ToOle(GetTextColor(color));
    
                shape.Fill.Visible = MsoTriState.msoTrue;
                shape.Fill.ForeColor.RGB = rgbBackground;
                shape.Line.ForeColor.RGB = rgbBorder;
                shape.TextFrame.TextRange.Font.Color.RGB = rgbText;
                shape.TextFrame2.AutoSize = MsoAutoSize.msoAutoSizeTextToFitShape;
                shape.TextFrame2.WordWrap = MsoTriState.msoTrue;
                shape.TextEffect.Text = text;
    
                return shape;
            }

    Thursday, March 29, 2012 9:08 AM

Answers