Hi I have the following mention code which sets the indent level for second paragraph . I have two issues with this code.
1. On selecting more than one paragraphs the indentation will work only on Last paragraph Selected.
2. The margin could not be set with this code . As I want "before text 1.2" and "Special Hanging by 0.46 cm" to be incorporated
Please help me in customizing this code and run the subroutine .
Thanks
1. On selecting more than one paragraphs the indentation will work only on Last paragraph Selected.
2. The margin could not be set with this code . As I want "before text 1.2" and "Special Hanging by 0.46 cm" to be incorporated
Code:
Sub selectedLevel()
Dim otr2 As TextRange2
' assumes the placeholder is selected
Set otr2 = ActiveWindow.Selection.ShapeRange(1).TextFrame2.TextRange.Paragraphs(GetPara)
With otr2.ParagraphFormat
.IndentLevel = 2
With oshp.TextFrame.Ruler
.Levels(1).FirstMargin = 10
.Levels(1).LeftMargin = 15
End With
End With
End Sub
Function GetPara() As Long
Dim lngStart As Long
Dim oshp As Shape
Dim L As Long
On Error Resume Next
lngStart = ActiveWindow.Selection.TextRange.Start
If err.Number <> 0 Then
Exit Function
End If
On Error GoTo 0
Set oshp = ActiveWindow.Selection.ShapeRange(1)
If (oshp.HasTextFrame) Then
For L = 1 To oshp.TextFrame2.TextRange.Paragraphs.Count
If (oshp.TextFrame2.TextRange.Paragraphs(L).Start <= lngStart) And ((oshp.TextFrame2.TextRange.Paragraphs(L).Start + oshp.TextFrame2.TextRange.Paragraphs(L).Length - 1) >= lngStart) Then
GetPara = L
Exit Function
End If
Next L
End If
End Function
Please help me in customizing this code and run the subroutine .
Thanks
Last edited: