2

Till now I solved most of my problems/questions by myself, simply searching for already existing threads...unfortunately this did not work for my current problem, so I thought I give it a try:

I am new to VBA and just recently started programming some useful marcos to automate/simplify slide development on PowerPoint 2007.

In one of them, I am trying to add shapes to a slide with a predefined bullet list. All works fine, except of getting the indentation of the bullets right. I'm not sure which code to use...

What I want to do is on the one hand define the space between bullet and text and on the other hand set the indentation before the bullet for the different levels of the bullet list.

I would really appreciate your help or any links to threads that adress this problem.

Code developed so far see below:

Sub PhaseWiz1Row2Phases()

Dim sld As Slide
Dim SlideIndex As Integer
Dim row1 As Shape

'###Only apply command to currentlty viewed slide###

'set the index number of the currently viewed slide as the variable "SlideIndex"
SlideIndex = ActiveWindow.View.Slide.SlideIndex
'set sld as the current slide
Set sld = ActivePresentation.Slides(SlideIndex)


'###Add and configure shapes to currently viewed slide###

'add first column to the currently viewed slide
 Set row1 = sld.Shapes.AddShape(msoShapeRectangle, _
     Left:=35.999, Top:=195.587, Width:=308.971, Height:=120)

        'configure column
        row1.Fill.Visible = msoFalse
        row1.Line.Visible = msoTrue
        row1.Line.Weight = 1#
        row1.Line.ForeColor.RGB = RGB(0, 40, 104)

        'Add and configure text
        row1.TextFrame.TextRange.Text = "Headline" _
            + Chr$(CharCode:=13) + "Text" + Chr$(CharCode:=13) + "Text" _
            + Chr$(CharCode:=13) + "Text" + Chr$(CharCode:=13) + "Text"

        row1.TextFrame.TextRange.Font.Size = 14
        row1.TextFrame.TextRange.Font.Name = "Verdana"
        row1.TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignLeft
        row1.TextFrame.VerticalAnchor = msoAnchorTop


        row1.TextFrame.TextRange.Paragraphs(3).IndentLevel = 2
        row1.TextFrame.TextRange.Paragraphs(4).IndentLevel = 3
        row1.TextFrame.TextRange.Paragraphs(5).IndentLevel = 4

            With row1.TextFrame.TextRange.Characters(1, 8)
                            .Font.Color.RGB = RGB(0, 174, 239)
                            .Font.Bold = msoTrue

            End With

            With row1.TextFrame.TextRange.Characters(9, 16)
                            .Font.Color.RGB = RGB(0, 40, 104)
                            .Font.Bold = msoFalse

            End With

            With row1.TextFrame.TextRange.Characters(10, 0)
                            .ParagraphFormat.Bullet.Character = 8226
                            .ParagraphFormat.Bullet.RelativeSize = 0.7

            End With

            With row1.TextFrame.TextRange.Characters(15, 0)
                            .ParagraphFormat.Bullet.Character = 45
                            .ParagraphFormat.Bullet.RelativeSize = 1.2
                            '.Paragraphs(3).IndentLevel = 2

            End With

            With row1.TextFrame.TextRange.Characters(20, 0)
                             .ParagraphFormat.Bullet.Character = 43
                             '.Paragraphs(3).IndentLevel = 2
            End With

            With row1.TextFrame.TextRange.Characters(25, 0)
                             .ParagraphFormat.Bullet.Character = 46
            End With

End Sub

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Tea_kay
  • 21
  • 1
  • 5
  • Do you already have something that you are working on that you could share with us instead of the community trying to create code from scratch? Showing some effort goes a long way at SO – Matt Mar 20 '15 at 12:52
  • Sorry for not posting the code before. Just updated the post. – Tea_kay Mar 20 '15 at 13:16

3 Answers3

0

The FirstLineIndent property on the ParagraphFormat object sets/retrieves the spacing between the bullet and the text.

Shyam Pillai
  • 576
  • 1
  • 4
  • 6
0

The code given below can be used to create a markdown file of bulleted and numbered lists in a textframe.

          For oPara = 1 To oShape.TextFrame.TextRange.Paragraphs.Count
            Select Case oShape.TextFrame.TextRange.Paragraphs(oPara).ParagraphFormat.Bullet.Type
              Case ppBulletMixed, ppBulletPicture, ppBulletUnnumbered   'Check if the paragraph is bulletted'
                Select Case oShape.TextFrame.TextRange.Paragraphs(oPara).IndentLevel
                  Case 1
                    Print #iFile, "* " & oShape.TextFrame.TextRange.Paragraphs(oPara).Text;
                  Case 2
                    Print #iFile, "  * " & oShape.TextFrame.TextRange.Paragraphs(oPara).Text;
                  Case 3
                    Print #iFile, "    * " & oShape.TextFrame.TextRange.Paragraphs(oPara).Text;
                  Case 4
                    Print #iFile, "      * " & oShape.TextFrame.TextRange.Paragraphs(oPara).Text;
                  Case Else
                    Print #iFile, "* " & oShape.TextFrame.TextRange.Paragraphs(oPara).Text;
                End Select
              Case ppBulletNumbered 'Check if the paragraph is numbered'
                Select Case oShape.TextFrame.TextRange.Paragraphs(oPara).IndentLevel
                  Case 1
                    Print #iFile, "1. " & oShape.TextFrame.TextRange.Paragraphs(oPara).Text;
                  Case 2
                    Print #iFile, "  1. " & oShape.TextFrame.TextRange.Paragraphs(oPara).Text;
                  Case 3
                    Print #iFile, "    1. " & oShape.TextFrame.TextRange.Paragraphs(oPara).Text;
                  Case 4
                    Print #iFile, "      1. " & oShape.TextFrame.TextRange.Paragraphs(oPara).Text;
                  Case Else
                    Print #iFile, "1. " & oShape.TextFrame.TextRange.Paragraphs(oPara).Text;
                End Select
              Case ppBulletNone 'extract unbulletted paras as is'
                Print #iFile, vbCrLf & oShape.TextFrame.TextRange.Paragraphs(oPara).Text & vbCrLf;
              Case Else
                Print #iFile, vbCrLf & oShape.TextFrame.TextRange.Paragraphs(oPara).Text & vbCrLf;
            End Select
          Next oPara
Harkirat
  • 27
  • 5
0

To define space between bullet and text you need to set FirstMarin and LeftMargin see my link (and but a star on it as you will face this problem ahead or if you have solution please answer my question) What is the correct way to implement bullet functionality in powerpoint Autoshape

  • Please don't link to your own question as an answer. Especially not if your question doesn't have an answer either. – THess Jan 14 '20 at 08:18