PDA

View Full Version : Bullet text formatting in slides using VBA PowerPoint



CuriosityBug
09-09-2019, 10:34 AM
Hello all,

As shown in the picture, I am trying to eliminate space that was created before "Point4". My aim is to make sure all bullet point text should start from same margin( i.e all P's form same margin eventually eliminating space marked as green in picture) . A macro which can run through bullets text in all slides and sets accordingly. Any insights are so helpful.

John Wilson
09-09-2019, 10:58 AM
Normally with modern versions you would use the TextFrame2 (and TextRange2) object. This allows you to set different indents for each paragraph.

Since you are trying to get them all the same this might work (using the easier to understand legacy TextFrame / TextRange object)

WORK ON a copy!


Sub bulletMe2()
Dim osld As Slide
Dim oshp As Shape
Dim L As Long
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.HasTextFrame Then
If oshp.TextFrame.HasText Then
With oshp.TextFrame.Ruler.Levels(1)
.FirstMargin = 0
.LeftMargin = 18.5 ' adjust as needed 72 per inch
End With
End If
End If
Next oshp
Next osld
End Sub

CuriosityBug
09-09-2019, 11:41 AM
Normally with modern versions you would use the TextFrame2 (and TextRange2) object. This allows you to set different indents for each paragraph.

Since you are trying to get them all the same this might work (using the easier to understand legacy TextFrame / TextRange object)

WORK ON a copy!


Sub bulletMe2()
Dim osld As Slide
Dim oshp As Shape
Dim L As Long
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.HasTextFrame Then
If oshp.TextFrame.HasText Then
With oshp.TextFrame.Ruler.Levels(1)
.FirstMargin = 0
.LeftMargin = 18.5 ' adjust as needed 72 per inch
End With
End If
End If
Next oshp
Next osld
End Sub

Thank you John. But, I am trying to get output as shown. The position of P...

John Wilson
09-10-2019, 05:18 AM
That is what should happen. Maybe you need to explain more fully what you need and what actually happened./

CuriosityBug
09-10-2019, 07:11 AM
Attaching picture where

1- represents Before macro is run
2- Expected output - eliminating the red colored space before P, all p's on same margin
3- Output after running the provided macro - The space between text box border and bullets got altered(i.e green colored space in case 1) instead of red space area.

John Wilson
09-10-2019, 08:48 AM
Can you post a downloadable sample.
Are you sure there aren't a couple of spaces before the last P?
If you put the cursor before the last P and post a screen shot showing the Ruler that would help.

25004

CuriosityBug
09-10-2019, 10:56 AM
Can you post a downloadable sample.
Are you sure there aren't a couple of spaces before the last P?
If you put the cursor before the last P and post a screen shot showing the Ruler that would help.

25004
Here is the sample slide below.

John Wilson
09-11-2019, 03:51 AM
You have leading spaces causing the problem.