Reputation: 79
I am trying to figure out how to identify bullet type and change it, i. e. check whether bullets used in whole presentation are square shaped bullets. If not, a macro should change the bullet type to square.
Example : In this picture, I would like to change round shapes bullets to square shaped bullets throughout the slide deck.
Upvotes: 3
Views: 3125
Reputation: 4913
The other 2 replies are adequate if the bullets have been created using only local formatting. If the presentation is a normal one, where the bullets are set in the slide master, those round bullets will keep coming back like a bad smell. Instead, change the bullets to square on the slide master, then reset all slides to force an update. This sets levels 1, 3 and 5 to square bullets:
Sub ChangeSomeBullets()
Dim oSlide As Slide
Dim oShape As Shape
For Each oShape In ActivePresentation.Designs(1).SlideMaster.Shapes
If oShape.Type = msoPlaceholder Then
If oShape.PlaceholderFormat.Type = ppPlaceholderBody Then
For X = 1 To oShape.TextFrame2.TextRange.Paragraphs.Count
Select Case X
Case 1, 3, 5
With oShape.TextFrame2.TextRange.Paragraphs(X).ParagraphFormat.Bullet
.Font.Name = "Wingdings"
.Character = 167
End With
End Select
Next X
End If
End If
Next oShape
For Each oSlide In ActivePresentation.Slides
oSlide.CustomLayout = oSlide.CustomLayout
Next oSlide
End Sub
Upvotes: 2
Reputation: 3877
You may play with this to see the parameters of your bullets.
I added some examples to explain how to set font, character, color etc.
Private Sub UnderstandAndChangeBullets()
Dim i As Integer
' loop through paragraphs of a shape:
With Application.ActivePresentation.Slides(5).Shapes(1).TextFrame
For i = 1 To .TextRange.Paragraphs.Count
With .TextRange.Paragraphs(i).ParagraphFormat.Bullet
If .Type = ppBulletUnnumbered Then
Debug.Print "Size: " & .RelativeSize, ' 1, 1.25, ...
Debug.Print "Color: " & .Font.Color.RGB, ' 0, RGB(255, 0, 0), vbRed, ...
Debug.Print "Font: " & .Font.Name, ' Arial, Wingdings, Symbol, ...
Debug.Print "Character: " & .Character ' 8226, 111, 167, 118, ...
End If
End With
Next i
End With
' ... or work with selected text:
With Application.ActiveWindow.Selection
If .Type = ppSelectionText Then
For i = 1 To .TextRange.Paragraphs.Count
' ... like above
Next i
End If
End With
End Sub
Upvotes: 0
Reputation: 33145
They don't make it easy. You need to change the BulletFormat.Character
property to the Unicode number of the shape you want. Here's what I did: I have a presentation where the second slide is Title and Content (two shapes). In the Content section I have four bullets. I changed the first one from the shape it is to the shape I want and run this:
Public Sub ChangeBullets()
Dim para As TextRange
For Each para In ActivePresentation.Slides(2).Shapes(2).TextFrame.TextRange.Paragraphs
Debug.Print para.ParagraphFormat.Bullet.Character, Left(para.Text, 20)
Next para
ActivePresentation.Slides(2).Shapes(2).TextFrame.TextRange.Paragraphs(1).ParagraphFormat.Bullet.Character = 9642
End Sub
This loops through the four bullets (para) in the second shape of the second slide and prints to the immediate window the character of the bullet followed by a little of the text (to make sure I was where I think I was). That produced:
111 Reality
9642 Consistency
9642 No Shortcuts
9642 The Right Tool
That tells me the bullet used to be 9642 (the same as its brothers) and I manually changed it to 111. Now that I know the Unicode number, I could loop through every slide, every shape, every paragraph and change the bullet number.
In the last line, I change the bullet back to 9642 just to make sure I could (and it worked).
Upvotes: 0