PDA

View Full Version : VBA - Setting Bulletpoint indent to 'Hanging' special



magemaester
11-19-2018, 09:11 PM
Hi internet,

I'm trying to write a macro to format the indentation of a bullet in Powerpoint - and I haven't found an existing solution to this problem yet on the internet.

Effectively. I'm trying to set:

Indentation Before Text: 0.3cm
Special: Hanging
By: 0.3cm

Now I can manipulate the indentation with

Shape.TextFrame.Ruler.Levels(1).LeftMargin and .FirstMargin, but I cannot set the Special hanging style to "Hanging" as opposed to "First Line"

Without this I'm unable to precisely control how I want my bullet to look.

Does anyone know what is the appropriate property to control the Special style here?

Thank you very much!

John Wilson
11-20-2018, 12:06 AM
You are using legacy code.

To do this you need to use the new code for TextRange2 that came from v. 2007

See if this does it


Sub fixindent()Dim oshp As Shape
Dim otr2 As TextRange2
Set oshp = ActiveWindow.Selection.ShapeRange(1)
Set otr2 = oshp.TextFrame2.TextRange
With otr2.ParagraphFormat
.LeftIndent = 0.3 * 28.3465
.FirstLineIndent = -(0.3 * 28.3465)
End With
End Sub

Or depending on exactly what you mean


Sub fixindent()Dim oshp As Shape
Dim otr2 As TextRange2
Set oshp = ActiveWindow.Selection.ShapeRange(1)
Set otr2 = oshp.TextFrame2.TextRange
With otr2.ParagraphFormat
.LeftIndent = 0.6 * 28.3465
.FirstLineIndent = -(0.3 * 28.3465)
End With
End Sub