|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
工作原因,设计了一个功能,查看标题格式是否正确,但是标题有一级标题,二级标题,三级标题,所以我就分别写了三种判断方式,然后回调。但是我感觉可以写成一个判断,自己尝试很久没搞出来,新人刚刚自学,想请教下老师怎么把这三种判断写成一种。正确的格式是(1.或者1.1. 或者1.1.1.)就有人经常忘记在最后的数字后面加点,工作要求把这种情况标记出来。
Sub First_Leve_title()
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^13[0-9] [A-Z]*^13"
.MatchWildcards = True
.Wrap = wdfindcontine
.Forward = True
Do
.Execute
If Not .Found Then
Exit Do
End If
If .Found Then
Selection.Comments.Add Range:=Selection.Range.Words(2), Text:="A " & ChrW(34) & "." & ChrW(34) & " is needed behind of The numbers (1.2.)."
End If
Loop
End With
Selection.HomeKey unit:=wdStory
End Sub
Sub second_title()
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^13[0-9].[0-9] [A-Z]*^13"
.MatchWildcards = True
.Wrap = wdfindcontine
.Forward = True
Do
.Execute
If Not .Found Then
Exit Do
End If
If .Found Then
Selection.Comments.Add Range:=Selection.Range.Words(2), Text:="A " & ChrW(34) & "." & ChrW(34) & " is needed behind of The numbers (1.2.)."
End If
Loop
End With
Selection.HomeKey unit:=wdStory
End Sub
Sub three_title()
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^13[0-9].[0-9].[0-9] [A-Z]*^13"
.MatchWildcards = True
.Wrap = wdfindcontine
.Forward = True
Do
.Execute
If Not .Found Then
Exit Do
End If
If .Found Then
Selection.Comments.Add Range:=Selection.Range.Words(2), Text:="A " & ChrW(34) & "." & ChrW(34) & " is needed behind of The numbers (1.2.)."
End If
Loop
End With
Selection.HomeKey unit:=wdStory
End Sub
|
|