1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
| Sub 段落处理(control As IRibbonControl) Application.ScreenUpdating = False For Each pg In Selection.Paragraphs If pg.Range.Information(wdWithInTable) = False Then If pg.OutlineLevel = wdOutlineLevel1 Then With pg.Range.ParagraphFormat .LeftIndent = CentimetersToPoints(0) .RightIndent = CentimetersToPoints(0) .SpaceBefore = 2.5 .SpaceBeforeAuto = False .SpaceAfter = 2.5 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpace1pt5 .Alignment = wdAlignParagraphCenter .FirstLineIndent = CentimetersToPoints(0) .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0
End With With pg.Range .Font.NameFarEast = "黑体" .Font.NameAscii = "Times New Roman" .Font.NameOther = "Times New Roman" .Font.Size = 20 .Font.Bold = True End With ElseIf pg.OutlineLevel = wdOutlineLevel2 Then With pg.Range.ParagraphFormat .LeftIndent = CentimetersToPoints(0) .RightIndent = CentimetersToPoints(0) .SpaceBefore = 2.5 .SpaceBeforeAuto = False .SpaceAfter = 2.5 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpace1pt5 .Alignment = wdAlignParagraphJustify .FirstLineIndent = CentimetersToPoints(0) .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0
End With With pg.Range .Font.NameFarEast = "黑体" .Font.NameAscii = "Times New Roman" .Font.NameOther = "Times New Roman" .Font.Size = 18 .Font.Bold = True
End With ElseIf pg.OutlineLevel = wdOutlineLevel3 Then With pg.Range.ParagraphFormat .LeftIndent = CentimetersToPoints(0) .RightIndent = CentimetersToPoints(0) .SpaceBefore = 2.5 .SpaceBeforeAuto = False .SpaceAfter = 2.5 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpace1pt5 .Alignment = wdAlignParagraphLeft .FirstLineIndent = CentimetersToPoints(0) .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0
End With With pg.Range .Font.NameFarEast = "黑体" .Font.NameAscii = "Times New Roman" .Font.NameOther = "Times New Roman" .Font.Size = 16 .Font.Bold = True
End With ElseIf pg.OutlineLevel = wdOutlineLevel4 Then With pg.Range.ParagraphFormat .LeftIndent = CentimetersToPoints(0) .RightIndent = CentimetersToPoints(0) .SpaceBefore = 2.5 .SpaceBeforeAuto = False .SpaceAfter = 2.5 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpace1pt5 .Alignment = wdAlignParagraphJustify .FirstLineIndent = CentimetersToPoints(0) .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0
End With With pg.Range .Font.NameFarEast = "仿宋" .Font.NameAscii = "Times New Roman" .Font.NameOther = "Times New Roman" .Font.Size = 16 .Font.Bold = True End With Else With pg.Range.ParagraphFormat .LeftIndent = CentimetersToPoints(0) .RightIndent = CentimetersToPoints(0) .SpaceBefore = 2.5 .SpaceBeforeAuto = False .SpaceAfter = 2.5 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpace1pt5 .Alignment = wdAlignParagraphJustify .FirstLineIndent = CentimetersToPoints(0.35) .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 2
End With With pg.Range .Font.NameFarEast = "仿宋" .Font.NameAscii = "Times New Roman" .Font.NameOther = "Times New Roman" .Font.Size = 14 .Font.Bold = False End With End If End If Next Application.ScreenUpdating = True End Sub Sub 表前单位格式(control As IRibbonControl) For Each pg In Selection.Paragraphs pg.IndentFirstLineCharWidth -10000 pg.IndentFirstLineCharWidth 2 pg.Range.Font.Bold = False With pg.Range.ParagraphFormat .LeftIndent = CentimetersToPoints(0) .RightIndent = CentimetersToPoints(0) .SpaceBefore = 0 .SpaceBeforeAuto = False .SpaceAfter = 0 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpaceSingle .Alignment = wdAlignParagraphJustify .FirstLineIndent = CentimetersToPoints(0) .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0 .LineUnitBefore = 0 .LineUnitAfter = 0 End With With pg.Range .Font.NameFarEast = "宋体" .Font.NameAscii = "Times New Roman" .Font.NameOther = "Times New Roman" .Font.Size = 10.5 .Font.Bold = False .ParagraphFormat.Alignment = wdAlignParagraphRight End With With pg.Range.ParagraphFormat .SpaceBefore = 0 .SpaceBeforeAuto = False .SpaceAfter = 0 .SpaceAfterAuto = False End With Next Application.ScreenUpdating = True End Sub Sub 表后注释格式(control As IRibbonControl) For Each pg In Selection.Paragraphs pg.IndentFirstLineCharWidth -10000 pg.IndentFirstLineCharWidth 2 pg.Range.Font.Bold = False With pg.Range.ParagraphFormat .LeftIndent = CentimetersToPoints(0) .RightIndent = CentimetersToPoints(0) .SpaceBefore = 0 .SpaceBeforeAuto = False .SpaceAfter = 0 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpaceSingle .Alignment = wdAlignParagraphJustify .FirstLineIndent = CentimetersToPoints(0) .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0 .LineUnitBefore = 0 .LineUnitAfter = 0 End With With pg.Range .Font.NameFarEast = "宋体" .Font.NameAscii = "Times New Roman" .Font.NameOther = "Times New Roman" .Font.Size = 10 .Font.Bold = False .ParagraphFormat.Alignment = wdAlignParagraphJustify End With With pg.Range.ParagraphFormat .SpaceBefore = 0 .SpaceBeforeAuto = False .SpaceAfter = 0 .SpaceAfterAuto = False End With Next Application.ScreenUpdating = True End Sub Sub 自动编号(control As IRibbonControl) Dim r As Range, P As Range, tpf, NF, NS, LI, FI tpf = "([一二三四五六七八九十]@)" NF = "(%1)" NS = wdListNumberStyleSimpChinNum3 LI = CentimetersToPoints(0) FI = CentimetersToPoints(0.74) Application.ScreenUpdating = False If Selection.Type = wdSelectionIP Then MsgBox "请选择范围!" Exit Sub Else Set r = Selection.Range Set P = Selection.Range End If With ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1) .NumberFormat = NF .TrailingCharacter = wdTrailingNone .NumberStyle = NS .NumberPosition = 0 .Alignment = wdListLevelAlignLeft .TextPosition = 0 .TabPosition = wdUndefined .ResetOnHigher = 0 .StartAt = 1 .LinkedStyle = "" End With ListGalleries(wdNumberGallery).ListTemplates(1).Name = "" With r.Find .ClearFormatting .Text = tpf .Forward = True .MatchWildcards = True Do While .Execute With .Parent pat = .Text If .End > P.End Then Exit Do ast = Asc(ActiveDocument.Range(Start:=.Start - 1, End:=.Start)) If ast = 13 Or ast = 12 Then .ListFormat.ApplyListTemplateWithLevel ListTemplate:= _ ListGalleries(wdNumberGallery).ListTemplates(1), ContinuePreviousList:= _ True, ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:= _ wdWord10ListBehavior With .ParagraphFormat .SpaceBeforeAuto = False .SpaceAfterAuto = False .LeftIndent = LI .FirstLineIndent = FI End With If .Text = pat Then .Delete End If End If .Start = .End End With Loop End With Application.ScreenUpdating = True MsgBox "完成" End Sub Sub 编号转文本(control As IRibbonControl) Dim kgslist As List i = MsgBox("点击确定则将该文档下所有编号转为文本", 1) If i = 1 Then For Each kgslist In ActiveDocument.Lists kgslist.ConvertNumbersToText Next End If End Sub
|