Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Setting the SpaceAfter for a paragraph causes huge spacing with certain shapes in VBA

I am trying to set the SpaceAfter property of a paragraph of text in a shape within PowerPoint with this line of code in the Immediate Window of the VBE:

ActiveWindow.Selection.ShapeRange(1).TextFrame.TextRange.ParagraphFormat.SpaceAfter=6

Open in new window

Sometimes it works and sometimes it doesn't. When it doesn't work, it appears to set the spacing to a very large value, which looks like it's 6 * Font Size * 1.2 = 115.2pt in my example with 16pt text!!!

But even more odd is that when I read back the value with the following line, I get 6:

?ActiveWindow.Selection.ShapeRange(1).TextFrame.TextRange.ParagraphFormat.SpaceAfter

Open in new window

The attached deck demonstrates the issue. The left and right shapes have their spacing set to the incorrect value whilst the centre one doesn't.

What is happening?
Paragraph-Spacing-Comparison.pptx
Microsoft ExcelVisual Basic ClassicMicrosoft PowerPointMicrosoft OfficeVBA

Avatar of undefined
Last Comment
Jamie Garroch (MVP)

8/22/2022 - Mon