Advertisement
cakyus

ParagraphStyleByLeftIndent

Mar 29th, 2011
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.03 KB | None | 0 0
  1. ' purpose: apply style to paragraph based on left indent value
  2. ' tags: VBA Macro Word 2007
  3.  
  4. Sub ParagraphStyleByLeftIndent()
  5.     Dim p As Paragraph
  6.     For Each p In ActiveDocument.Paragraphs
  7.         If p.Style = ActiveDocument.Styles("List Style 1") Then
  8.         ElseIf p.Style = ActiveDocument.Styles("List Style 2") Then
  9.         ElseIf p.Style = ActiveDocument.Styles("List Style 3") Then
  10.         ElseIf p.Style = ActiveDocument.Styles("List Style 4") Then
  11.         ElseIf p.Format.LeftIndent = 36 Then
  12.             p.Style = ActiveDocument.Styles("List Style 1")
  13.         ElseIf p.Format.LeftIndent = 57.6 Then
  14.             p.Style = ActiveDocument.Styles("List Style 2")
  15.         ElseIf p.Format.LeftIndent = 79.2 Then
  16.             p.Style = ActiveDocument.Styles("List Style 3")
  17.         ElseIf p.Format.LeftIndent = 104.4 Then
  18.             p.Style = ActiveDocument.Styles("List Style 4")
  19.         Else
  20.             Debug.Print p.Format.LeftIndent
  21.             Debug.Print p.Range.Text
  22.             Exit Sub
  23.         End If
  24.     Next
  25. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement