0

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

    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 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

1 Answer 1

0

Hi I have worked out with my first question pertaining to Margin .

However when I select the multiple paragraphs. All the parapraphs doesn't get indented

The code below is for having the Predefined MARGIN

    Sub selectedLevel()
    Dim otr2 As TextRange2
Set otr2 = ActiveWindow.Selection.ShapeRange(1).TextFrame2.TextRange.Paragraphs(GetPara)
With otr2.ParagraphFormat
.LeftIndent = 0.9 * 39
.FirstLineIndent = -(0.5 * 29)
  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 with applying this subroutine in all paragraphs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .