Consulting

Results 1 to 8 of 8

Thread: Bullet text formatting in slides using VBA PowerPoint

  1. #1

    Bullet text formatting in slides using VBA PowerPoint

    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.
    Attached Images Attached Images

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,870
    Location
    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
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    Quote Originally Posted by John Wilson View Post
    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...
    Attached Images Attached Images

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,870
    Location
    That is what should happen. Maybe you need to explain more fully what you need and what actually happened./
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    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.
    Attached Images Attached Images

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,870
    Location
    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.

    ruler.jpg
    Attached Images Attached Images
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  7. #7
    Quote Originally Posted by John Wilson View Post
    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.

    ruler.jpg
    Here is the sample slide below.
    Attached Files Attached Files

  8. #8
    VBAX Master
    Joined
    Feb 2007
    Posts
    1,870
    Location
    You have leading spaces causing the problem.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •