[VB 스크립트 메모] [for WORD] 정책과 법규 조판

28626 단어
아주 오래 전에 인터넷에서 찾는 정책과 법조를 조판한 후에 남겨 두어야 했는데 조판은 매우 번거로웠다. 일찍이 두 단락의 코드를 써서 적지 않은 수고를 덜었고 전기에 써야 하기 때문에 찾을 수 없었다.우연히 원고를 끝까지 뒤져서 서둘러 백업을 하다.
법조
***  ***
Sub TypeSet()
    Application.ScreenUpdating = False
    '------------------------------------------      ------------------------------------------
    ActiveDocument.Content.Find.Execute FindText:="(", ReplaceWith:="(", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:=")", ReplaceWith:=")", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:=" ", ReplaceWith:="", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:=" ", ReplaceWith:="", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:=Chr(9), ReplaceWith:="", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:="[", ReplaceWith:="〔", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:="]", ReplaceWith:="〕", Replace:=wdReplaceAll
    '------------------------------------------      ------------------------------------------
    For p = ActiveDocument.Paragraphs.Count To 1 Step -1
        If Len(ActiveDocument.Paragraphs(p).Range) = 1 Then ActiveDocument.Paragraphs(p).Range.Delete
    Next
    '------------------------------------------      ------------------------------------------
    Dim D1 As Object
    Set D1 = CreateObject("scripting.dictionary")
    Dim n&
    For n = 1 To 250
        D1(n) = CChinese(n)
    Next
    '------------------------------------------      ------------------------------------------
'    Dim D2 As Object
'    Set D2 = CreateObject("scripting.dictionary")
'    For i = 1 To 40
'        D2(i) = CStr(i)
'    Next
    '----------------------------------------------------------------------------------------------
    Dim Pstr
    Pstr = ""
    '------------------------------------------      ------------------------------------------
    With ActiveDocument.Paragraphs(1).Range.Font
        .Size = 18
        .Name = "  "
        .Bold = True
    End With
    With ActiveDocument.Paragraphs(1).Range.ParagraphFormat
        .Alignment = wdAlignParagraphCenter         '    
        .OutlineLevel = wdOutlineLevel1             '    
        .CharacterUnitFirstLineIndent = 0           '    
        .LineSpacingRule = wdLineSpaceSingle        '  (  :    )
        .LineUnitBefore = 0                         '    (  :    )
        .LineUnitAfter = 1                          '    (  :    )
'''        .SpaceBefore = 0
'''        .SpaceAfter = 5
'''        .FirstLineIndent = CentimetersToPoints(0)
'        .LeftIndent = CentimetersToPoints(0)
'        .RightIndent = CentimetersToPoints(0)
'        .SpaceBeforeAuto = False
'        .SpaceAfterAuto = False
'        .WidowControl = True
'        .KeepWithNext = False
'        .KeepTogether = False
'        .PageBreakBefore = False
'        .NoLineNumber = False
'        .Hyphenation = True
'        .CharacterUnitLeftIndent = 0
'        .CharacterUnitRightIndent = 0
'        .MirrorIndents = False
'        .TextboxTightWrap = wdTightNone
'        .CollapsedByDefault = False
'        .AutoAdjustRightIndent = True
'        .DisableLineHeightGrid = False
'        .FarEastLineBreakControl = True
'        .WordWrap = True
'        .HangingPunctuation = True
'        .HalfWidthPunctuationOnTopOfLine = False
'        .AddSpaceBetweenFarEastAndAlpha = True
'        .AddSpaceBetweenFarEastAndDigit = True
'        .BaseLineAlignment = wdBaselineAlignAuto
    End With
'---------------------------------------------------------------------------------------------------------------
    For p = 2 To ActiveDocument.Paragraphs.Count
        Pstr = ""
        For i = 1 To D1.Count
            Pstr = ActiveDocument.Paragraphs(p)
            '------------------------------------------      ------------------------------------------
            If Pstr Like " " & D1(i) & " *" Then
                With ActiveDocument.Paragraphs(p)
                    m = InStr(.Range, " ")
                    .Range.Text = Left(.Range, m) & vbTab & Right(.Range, Len(.Range) - m)
                End With
                With ActiveDocument.Paragraphs(p).Range.Font
                    .Size = 15
                    .Name = "  "
                    .Bold = True
                End With
                With ActiveDocument.Paragraphs(p).Range.ParagraphFormat
                    .Alignment = wdAlignParagraphCenter         '    
                    .OutlineLevel = wdOutlineLevel2             '    
                    .CharacterUnitFirstLineIndent = 0           '    
                    .LineSpacingRule = wdLineSpaceSingle        '  (  :    )
                    .LineUnitBefore = 1                         '    (  :    )
                    .LineUnitAfter = 0.5                        '    (  :    )
'                    .LeftIndent = CentimetersToPoints(0)
'                    .RightIndent = CentimetersToPoints(0)
'                    .SpaceBefore = 5
'                    .SpaceBeforeAuto = False
'                    .SpaceAfter = 2.5
'                    .SpaceAfterAuto = False
'                    .WidowControl = True
'                    .KeepWithNext = False
'                    .KeepTogether = False
'                    .PageBreakBefore = False
'                    .NoLineNumber = False
'                    .Hyphenation = True
'                    .FirstLineIndent = CentimetersToPoints(0)
'                    .CharacterUnitLeftIndent = 0
'                    .CharacterUnitRightIndent = 0
'                    .MirrorIndents = False
'                    .TextboxTightWrap = wdTightNone
'                    .CollapsedByDefault = False
'                    .AutoAdjustRightIndent = True
'                    .DisableLineHeightGrid = False
'                    .FarEastLineBreakControl = True
'                    .WordWrap = True
'                    .HangingPunctuation = True
'                    .HalfWidthPunctuationOnTopOfLine = False
'                    .AddSpaceBetweenFarEastAndAlpha = True
'                    .AddSpaceBetweenFarEastAndDigit = True
'                    .BaseLineAlignment = wdBaselineAlignAuto
                End With
                GoTo 100
            '------------------------------------------      ------------------------------------------
            ElseIf Pstr Like " " & D1(i) & " *" Then
                With ActiveDocument.Paragraphs(p)
                    m = InStr(.Range, " ")
                    .Range.Text = Left(.Range, m) & vbTab & Right(.Range, Len(.Range) - m)
                End With
                With ActiveDocument.Paragraphs(p).Range.Font
                    .Size = 15
                    .Name = "  "
                    .Bold = True
                End With
                With ActiveDocument.Paragraphs(p).Range.ParagraphFormat
                    .Alignment = wdAlignParagraphCenter         '    
                    .OutlineLevel = wdOutlineLevel3             '    
                    .CharacterUnitFirstLineIndent = 0           '    
                    .LineSpacingRule = wdLineSpaceSingle        '  (  :    )
                    .LineUnitBefore = 0.5                       '    (  :    )
                    .LineUnitAfter = 0                          '    (  :    )
                End With
                GoTo 100
            '------------------------------------------        ------------------------------------------
            ElseIf Pstr Like " " & D1(i) & " *" Then
                With ActiveDocument.Paragraphs(p)
                    m = InStr(.Range, " ")
                    .Range.Text = Left(.Range, m) & vbTab & Right(.Range, Len(.Range) - m)
                End With
                With ActiveDocument.Paragraphs(p).Range.Font
                    .Size = 15
                    .Name = "  "
                    .Bold = False
                End With
                With ActiveDocument.Paragraphs(p).Range.ParagraphFormat
                    .Alignment = wdAlignParagraphLeft           '    
                    .OutlineLevel = wdOutlineLevelBodyText      '    
                    .CharacterUnitFirstLineIndent = 2           '    
                    .LineSpacingRule = wdLineSpaceSingle        '  (  :    )
                    .LineUnitBefore = 0                         '    (  :    )
                    .LineUnitAfter = 0                          '    (  :    )
                End With
                GoTo 100
            End If
        Next
        '------------------------------------------        ------------------------------------------
        With ActiveDocument.Paragraphs(p).Range.Font
            .Size = 15
            .Name = "  "
            .Bold = False
        End With
        With ActiveDocument.Paragraphs(p).Range.ParagraphFormat
            .Alignment = wdAlignParagraphLeft           '    
            .OutlineLevel = wdOutlineLevelBodyText      '    
            .CharacterUnitFirstLineIndent = 2           '    
            .LineSpacingRule = wdLineSpaceSingle        '  (  :    )
            .LineUnitBefore = 0                         '    (  :    )
            .LineUnitAfter = 0                          '    (  :    )
        End With
        '------------------------------------------------------------------------
100
    Next
    '------------------------------------------    ------------------------------------------
    Do While Len(ActiveDocument.Paragraphs(ActiveDocument.Paragraphs.Count).Range) = 1
        ActiveDocument.Paragraphs(ActiveDocument.Paragraphs.Count).Range.Delete
    Loop
    Dim Dept$, s%
    Dept = "         "
    s = 0
    For p = ActiveDocument.Paragraphs.Count - 1 To ActiveDocument.Paragraphs.Count
        Pstr = ActiveDocument.Paragraphs(p)
        If Len(Pstr) < 20 And (InStr(Dept, Mid(Pstr, Len(Pstr) - 1, 1)) <> 0) Then
            s = 1
            With ActiveDocument.Paragraphs(p).Range.ParagraphFormat
                .Alignment = wdAlignParagraphRight
                .LineUnitBefore = 1.5
            End With
        ElseIf Len(Pstr) < 20 And (Pstr Like "* * * ?") Then
            ActiveDocument.Paragraphs(p).Range.ParagraphFormat.Alignment = wdAlignParagraphRight
            If s = 0 Then ActiveDocument.Paragraphs(p).Range.ParagraphFormat.LineUnitBefore = 1.5
        End If
    Next
    '------------------------------------------      ------------------------------------------
    Pstr = ActiveDocument.Paragraphs(2)
    If (Pstr Like "*〔*〕*" Or Pstr Like "(* * * *)?") And Len(Pstr) < 30 Then
        ActiveDocument.Paragraphs(1).Range.ParagraphFormat.LineUnitAfter = 0.01
        With ActiveDocument.Paragraphs(2).Range.ParagraphFormat
            .CharacterUnitFirstLineIndent = 0.01
            .Alignment = wdAlignParagraphCenter
            .LineUnitAfter = 1
        End With
    End If
    Pstr = ""
    '------------------------------------------      ------------------------------------------
    For p = 2 To 4
        Pstr = ActiveDocument.Paragraphs(p)
        If Pstr Like "*:?" And Len(Pstr) < 40 Then
            ActiveDocument.Paragraphs(p).Range.ParagraphFormat.CharacterUnitFirstLineIndent = 0.01
        End If
    Next
    '----------------------------------------------------------------------------------------------
    Application.ScreenUpdating = True
End Sub


Private Function CChinese(StrEng) As String '     

    If Not IsNumeric(StrEng) Or StrEng Like "*.*" Or StrEng Like "*-*" Then
        If Trim(StrEng) <> "" Then MsgBox "     "
        CChinese = "": Exit Function
    End If
    
    Dim intLen As Integer, intCounter As Integer
    Dim strCh As String, strTempCh As String
    Dim strSeqCh1 As String, strSeqCh2 As String
    Dim strEng2Ch As String
    strEng2Ch = "          "
    strSeqCh1 = "                "
    strSeqCh2 = "    "
    StrEng = CStr(CDec(StrEng))
    intLen = Len(StrEng)
    
    For intCounter = 1 To intLen
        strTempCh = Mid(strEng2Ch, Val(Mid(StrEng, intCounter, 1)) + 1, 1)
        If strTempCh = " " And intLen <> 1 Then
            If Mid(StrEng, intCounter + 1, 1) = "0" Or (intLen - intCounter + 1) Mod 4 = 1 Then
                strTempCh = ""
            End If
        Else
            strTempCh = strTempCh & Trim(Mid(strSeqCh1, intLen - intCounter + 1, 1))
        End If
        
        If (intLen - intCounter + 1) Mod 4 = 1 Then
            strTempCh = strTempCh & Mid(strSeqCh2, (intLen - intCounter + 1) \ 4 + 1, 1)
            If intCounter > 3 Then
                If Mid(StrEng, intCounter - 3, 4) = "0000" Then strTempCh = Left(strTempCh, Len(strTempCh) - 1)
            End If
        End If
        strCh = strCh & Trim(strTempCh)
    Next
    If strCh Like "  *" Then strCh = Right(strCh, Len(strCh) - 1)
    CChinese = strCh
End Function

【정책】
***  ***
Sub TypeSet()
    Application.ScreenUpdating = False
    '------------------------------------------      ------------------------------------------
    ActiveDocument.Content.Find.Execute FindText:="(", ReplaceWith:="(", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:=")", ReplaceWith:=")", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:=" ", ReplaceWith:="", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:=" ", ReplaceWith:="", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:=Chr(9), ReplaceWith:="", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:="[", ReplaceWith:="〔", Replace:=wdReplaceAll
    ActiveDocument.Content.Find.Execute FindText:="]", ReplaceWith:="〕", Replace:=wdReplaceAll
    '------------------------------------------      ------------------------------------------
    For p = ActiveDocument.Paragraphs.Count To 1 Step -1
        If Len(ActiveDocument.Paragraphs(p).Range) = 1 Then ActiveDocument.Paragraphs(p).Range.Delete
    Next
    '------------------------------------------      ------------------------------------------
    Dim D1 As Object
    Set D1 = CreateObject("scripting.dictionary")
    D1(1) = " "
    D1(2) = " "
    D1(3) = " "
    D1(4) = " "
    D1(5) = " "
    D1(6) = " "
    D1(7) = " "
    D1(8) = " "
    D1(9) = " "
    D1(10) = " "
    D1(11) = "  "
    D1(12) = "  "
    D1(13) = "  "
    D1(14) = "  "
    D1(15) = "  "
    D1(16) = "  "
    D1(17) = "  "
    D1(18) = "  "
    D1(19) = "  "
    D1(20) = "  "
    D1(21) = "   "
    D1(22) = "   "
    D1(23) = "   "
    D1(24) = "   "
    D1(25) = "   "
    D1(26) = "   "
    D1(27) = "   "
    D1(28) = "   "
    D1(29) = "   "
    D1(30) = "  "
    D1(31) = "   "
    D1(32) = "   "
    D1(33) = "   "
    D1(34) = "   "
    D1(35) = "   "
    D1(36) = "   "
    D1(37) = "   "
    D1(38) = "   "
    D1(39) = "   "
    D1(40) = "  "
    '------------------------------------------      ------------------------------------------
    Dim D2 As Object
    Set D2 = CreateObject("scripting.dictionary")
    For i = 1 To 40
        D2(i) = CStr(i)
    Next
    '----------------------------------------------------------------------------------------------
    Dim Pstr
    Pstr = ""
    '------------------------------------------      ------------------------------------------
    With ActiveDocument.Paragraphs(1).Range.Font
        .Size = 18
        .Name = "  "
        .Bold = True
    End With
    With ActiveDocument.Paragraphs(1).Range.ParagraphFormat
        .Alignment = wdAlignParagraphCenter
        .LeftIndent = CentimetersToPoints(0)
        .RightIndent = CentimetersToPoints(0)
        .SpaceBefore = 0
        .SpaceBeforeAuto = False
        .SpaceAfter = 5
        .SpaceAfterAuto = False
        .LineSpacingRule = wdLineSpaceSingle
        .Alignment = wdAlignParagraphCenter
        .WidowControl = True
        .KeepWithNext = False
        .KeepTogether = False
        .PageBreakBefore = False
        .NoLineNumber = False
        .Hyphenation = True
        .FirstLineIndent = CentimetersToPoints(0)
        .OutlineLevel = wdOutlineLevel1
        .CharacterUnitLeftIndent = 0
        .CharacterUnitRightIndent = 0
        .CharacterUnitFirstLineIndent = 0
        .LineUnitBefore = 0
        .LineUnitAfter = 1
        .MirrorIndents = False
        .TextboxTightWrap = wdTightNone
        .CollapsedByDefault = False
        .AutoAdjustRightIndent = True
        .DisableLineHeightGrid = False
        .FarEastLineBreakControl = True
        .WordWrap = True
        .HangingPunctuation = True
        .HalfWidthPunctuationOnTopOfLine = False
        .AddSpaceBetweenFarEastAndAlpha = True
        .AddSpaceBetweenFarEastAndDigit = True
        .BaseLineAlignment = wdBaselineAlignAuto
    End With
'---------------------------------------------------------------------------------------------------------------
    For p = 2 To ActiveDocument.Paragraphs.Count
        Pstr = ""
        For i = 1 To D1.Count
            Pstr = ActiveDocument.Paragraphs(p)
            '------------------------------------------      ------------------------------------------
            If Pstr Like D1(i) & "、*" Then
                With ActiveDocument.Paragraphs(p).Range.Font
                    .Size = 15
                    .Name = "  "
                    .Bold = True
                End With
                With ActiveDocument.Paragraphs(p).Range.ParagraphFormat
                    .LeftIndent = CentimetersToPoints(0)
                    .RightIndent = CentimetersToPoints(0)
                    .SpaceBefore = 5
                    .SpaceBeforeAuto = False
                    .SpaceAfter = 2.5
                    .SpaceAfterAuto = False
                    .LineSpacingRule = wdLineSpaceSingle
                    .Alignment = wdAlignParagraphLeft
                    .WidowControl = True
                    .KeepWithNext = False
                    .KeepTogether = False
                    .PageBreakBefore = False
                    .NoLineNumber = False
                    .Hyphenation = True
                    .FirstLineIndent = CentimetersToPoints(0.35)
                    .OutlineLevel = wdOutlineLevel2
                    .CharacterUnitLeftIndent = 0
                    .CharacterUnitRightIndent = 0
                    .CharacterUnitFirstLineIndent = 2
                    .LineUnitBefore = 1
                    .LineUnitAfter = 0.5
                    .MirrorIndents = False
                    .TextboxTightWrap = wdTightNone
                    .CollapsedByDefault = False
                    .AutoAdjustRightIndent = True
                    .DisableLineHeightGrid = False
                    .FarEastLineBreakControl = True
                    .WordWrap = True
                    .HangingPunctuation = True
                    .HalfWidthPunctuationOnTopOfLine = False
                    .AddSpaceBetweenFarEastAndAlpha = True
                    .AddSpaceBetweenFarEastAndDigit = True
                    .BaseLineAlignment = wdBaselineAlignAuto
                End With
                GoTo 100
            '------------------------------------------      ------------------------------------------
            ElseIf Pstr Like "(" & D1(i) & ")*" Then
                With ActiveDocument.Paragraphs(p).Range.Font
                    .Size = 15
                    .Name = "  "
                    .Bold = True
                End With
                With ActiveDocument.Paragraphs(p).Range.ParagraphFormat
                    .LeftIndent = CentimetersToPoints(0)
                    .RightIndent = CentimetersToPoints(0)
                    .SpaceBefore = 2.5
                    .SpaceBeforeAuto = False
                    .SpaceAfter = 0
                    .SpaceAfterAuto = False
                    .LineSpacingRule = wdLineSpaceSingle
                    .Alignment = wdAlignParagraphLeft
                    .WidowControl = True
                    .KeepWithNext = False
                    .KeepTogether = False
                    .PageBreakBefore = False
                    .NoLineNumber = False
                    .Hyphenation = True
                    .FirstLineIndent = CentimetersToPoints(0.35)
                    .OutlineLevel = wdOutlineLevel3
                    .CharacterUnitLeftIndent = 0
                    .CharacterUnitRightIndent = 0
                    .CharacterUnitFirstLineIndent = 2
                    .LineUnitBefore = 0.5
                    .LineUnitAfter = 0
                    .MirrorIndents = False
                    .TextboxTightWrap = wdTightNone
                    .CollapsedByDefault = False
                    .AutoAdjustRightIndent = True
                    .DisableLineHeightGrid = False
                    .FarEastLineBreakControl = True
                    .WordWrap = True
                    .HangingPunctuation = True
                    .HalfWidthPunctuationOnTopOfLine = False
                    .AddSpaceBetweenFarEastAndAlpha = True
                    .AddSpaceBetweenFarEastAndDigit = True
                    .BaseLineAlignment = wdBaselineAlignAuto
                End With
                GoTo 100
            '------------------------------------------      ------------------------------------------
            ElseIf (Pstr Like D2(i) & ".*") Or (Pstr Like D2(i) & "、*") Then
                With ActiveDocument.Paragraphs(p).Range.Font
                    .Size = 15
                    .Name = "  "
                    .Bold = False
                End With
                With ActiveDocument.Paragraphs(p).Range.ParagraphFormat
                    .LeftIndent = CentimetersToPoints(0)
                    .RightIndent = CentimetersToPoints(0)
                    .SpaceBefore = 0
                    .SpaceBeforeAuto = False
                    .SpaceAfter = 0
                    .SpaceAfterAuto = False
                    .LineSpacingRule = wdLineSpaceSingle
                    .Alignment = wdAlignParagraphLeft
                    .WidowControl = True
                    .KeepWithNext = False
                    .KeepTogether = False
                    .PageBreakBefore = False
                    .NoLineNumber = False
                    .Hyphenation = True
                    .FirstLineIndent = CentimetersToPoints(0.35)
                    .OutlineLevel = wdOutlineLevel4
                    .CharacterUnitLeftIndent = 0
                    .CharacterUnitRightIndent = 0
                    .CharacterUnitFirstLineIndent = 2
                    .LineUnitBefore = 0
                    .LineUnitAfter = 0
                    .MirrorIndents = False
                    .TextboxTightWrap = wdTightNone
                    .CollapsedByDefault = False
                    .AutoAdjustRightIndent = True
                    .DisableLineHeightGrid = False
                    .FarEastLineBreakControl = True
                    .WordWrap = True
                    .HangingPunctuation = True
                    .HalfWidthPunctuationOnTopOfLine = False
                    .AddSpaceBetweenFarEastAndAlpha = True
                    .AddSpaceBetweenFarEastAndDigit = True
                    .BaseLineAlignment = wdBaselineAlignAuto
                End With
                GoTo 100
            End If
        Next
        '------------------------------------------    ------------------------------------------
        With ActiveDocument.Paragraphs(p).Range.Font
            .Size = 15
            .Name = "  "
            .Bold = False
        End With
        With ActiveDocument.Paragraphs(p).Range.ParagraphFormat
            .LeftIndent = CentimetersToPoints(0)
            .RightIndent = CentimetersToPoints(0)
            .SpaceBefore = 0
            .SpaceBeforeAuto = False
            .SpaceAfter = 0
            .SpaceAfterAuto = False
            .LineSpacingRule = wdLineSpaceSingle
            .Alignment = wdAlignParagraphLeft
            .WidowControl = True
            .KeepWithNext = False
            .KeepTogether = False
            .PageBreakBefore = False
            .NoLineNumber = False
            .Hyphenation = True
            .FirstLineIndent = CentimetersToPoints(0.35)
            .OutlineLevel = wdOutlineLevelBodyText
            .CharacterUnitLeftIndent = 0
            .CharacterUnitRightIndent = 0
            .CharacterUnitFirstLineIndent = 2
            .LineUnitBefore = 0
            .LineUnitAfter = 0
            .MirrorIndents = False
            .TextboxTightWrap = wdTightNone
            .CollapsedByDefault = False
            .AutoAdjustRightIndent = True
            .DisableLineHeightGrid = False
            .FarEastLineBreakControl = True
            .WordWrap = True
            .HangingPunctuation = True
            .HalfWidthPunctuationOnTopOfLine = False
            .AddSpaceBetweenFarEastAndAlpha = True
            .AddSpaceBetweenFarEastAndDigit = True
            .BaseLineAlignment = wdBaselineAlignAuto
        End With
        '------------------------------------------------------------------------
100
    Next
    '------------------------------------------    ------------------------------------------
    Do While Len(ActiveDocument.Paragraphs(ActiveDocument.Paragraphs.Count).Range) = 1
        ActiveDocument.Paragraphs(ActiveDocument.Paragraphs.Count).Range.Delete
    Loop
    Dim Dept$, s%
    Dept = "         "
    s = 0
    For p = ActiveDocument.Paragraphs.Count - 1 To ActiveDocument.Paragraphs.Count
        Pstr = ActiveDocument.Paragraphs(p)
        If Len(Pstr) < 20 And (InStr(Dept, Mid(Pstr, Len(Pstr) - 1, 1)) <> 0) Then
            s = 1
            With ActiveDocument.Paragraphs(p).Range.ParagraphFormat
                .Alignment = wdAlignParagraphRight
                .LineUnitBefore = 1.5
            End With
        ElseIf Len(Pstr) < 20 And (Pstr Like "* * * ?") Then
            ActiveDocument.Paragraphs(p).Range.ParagraphFormat.Alignment = wdAlignParagraphRight
            If s = 0 Then ActiveDocument.Paragraphs(p).Range.ParagraphFormat.LineUnitBefore = 1.5
        End If
    Next
    '------------------------------------------      ------------------------------------------
    Pstr = ActiveDocument.Paragraphs(2)
    If (Pstr Like "*〔*〕*" Or Pstr Like "(* * * *)?") And Len(Pstr) < 30 Then
        ActiveDocument.Paragraphs(1).Range.ParagraphFormat.LineUnitAfter = 0.01
        With ActiveDocument.Paragraphs(2).Range.ParagraphFormat
            .CharacterUnitFirstLineIndent = 0.01
            .Alignment = wdAlignParagraphCenter
            .LineUnitAfter = 1
        End With
    End If
    Pstr = ""
    '------------------------------------------      ------------------------------------------
    For p = 2 To 4
        Pstr = ActiveDocument.Paragraphs(p)
        If Pstr Like "*:?" And Len(Pstr) < 50 Then
            ActiveDocument.Paragraphs(p).Range.ParagraphFormat.CharacterUnitFirstLineIndent = 0.01
        End If
    Next
    '----------------------------------------------------------------------------------------------
    Application.ScreenUpdating = True
End Sub

좋은 웹페이지 즐겨찾기