Set overflow in powerpoint form

So, I have a form that I programmatically generate, when it has a small amount of text, it looks like this:

Style is correct, vertically aligned to top

If I add a huge amount of text, it follows from the form, for example:

Vertical alignment starts outside of boundaries

I want to do this to hide the overflow and make the text start at the top of the form (currently the text starts at a position above the top of the form)

I have not yet found a lot of information about this, here is the code that I use for the text inside the form:

var shape = slide.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, left, top, width, height); var textRange2 = shape.TextFrame.TextRange.InsertAfter(description); textRange2.Font.Size = 10; shape.TextFrame.TextRange.Paragraphs().ParagraphFormat.Alignment = PpParagraphAlignment.ppAlignLeft; shape.TextFrame.TextRange.Paragraphs().Font.Name = "Consolas"; shape.TextFrame.TextRange.Paragraphs().Font.Color.RGB = foregroundColor; 

Last, I know that I can just limit the line, but that would cause problems for the user. I want him to be able to resize the shape manually if there is too much text so that there is nothing. Basically, I just want the equivalent of css overflow: a hidden rule.

One option for some users may be as follows:

 shape.TextFrame.AutoSize = PpAutoSize.ppAutoSizeShapeToFitText; 

This will resize the form to fit the text, it should also be possible to resize the text to fit the form (change the font size), however I cannot find the function.

Thanks guys,

+4
source share
2 answers

So obviously

 shape.TextFrame.AutoSize 

accepts an enumerated PpAutoSize that has PpAutoSize.ppAutoSizeShapeToFitText; which can be used

whereas

 shape.TextFrame2.AutoSize 

accepts an enumerated MsoAutoSize that has MsoAutoSize.msoAutoSizeTextToFitShape;

So basically, if you change the text frame that you use in TextFrame2 instead of TextFrame, you can resize the text to fit the form automatically.

 shape.TextFrame2.AutoSize = MsoAutoSize.msoAutoSizeTextToFitShape; 
+3
source

In Powerpoint directly - there is an opportunity to do this. Based on the placement in the menu, I would suggest that it is in form. TextFrame.AutoSize Property - perhaps a "mixed" option? The PowerPoint object model is a huge mess - so it could be some other Strange property ...

0
source

Source: https://habr.com/ru/post/1481753/


All Articles