Facing issue while setting autofit property to AutoShape

Hi,

I am using “TextAutofitType.Shape” property which defines “Shape autofit. Shape size will be changed to fit the text”.

IAutoShape ashp = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 50, 30, 0, 0, false);
ashp.addTextFrame(a);
ashp.getTextFrame().getTextFrameFormat().setAutofitType(TextAutofitType.Shape);

But in actual it’s not changing the size of a shape.

Below zip contains :

  1. Code package I am using
  2. Result (Actual and Expected results).

dynamicTextHandleBar.zip (189.9 KB)

Please let me know what I am doing wrong.
Thanks.

@saquibs,
By default, text wrapping is enabled for the text frames. You should disable the text wrapping as follows:

ashp.getTextFrame().getTextFrameFormat().setWrapText(NullableBool.False);

API Reference: ITextFrameFormat interface