|
pipiludaxian 发表于 2014-9-19 13:54
Sub get_specitied_apar()
Dim apar As Paragraph
For Each apar In ActiveDocument.Paragraphs
10个汉字
Sub MeThee()
Dim aCount&, i&, aPara As Paragraph, aText$
With ActiveDocument
aCount = .Paragraphs.Count
For i = 1 To aCount
Set aPara = .Paragraphs(i)
If aPara.Range.Information(wdWithInTable) = False Then '不在表格中
aText = myRegExp(aPara.Range.Text, "[^一-﨩]")
'If Len(aText) < 10 And Len(aText) > 0 Then aPara.Range.Style = wdStyleHeading1
If Len(aText) < 10 And Len(aText) > 0 Then aPara.Range.Style = .Styles("标题 1") '汉字个数(1,10]
End If
Next
End With
End Sub
Public Function myRegExp(ByVal str$, ByVal aPattern$) As Long
On Error Resume Next
With CreateObject("Vbscript.RegExp")
.Global = True
.Pattern = aPattern
myRegExp = .Replace(str, "")
End With
End Function
|
|