|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
word 2016中,我想按下第一个宏按钮,能运行第一段代码。按下第二个按钮,能运行第二段代码,请问这样可以实现吗?
Sub 个数()
With ActiveDocument.Content.Find
.MatchWildcards = True
.Font.Underline = wdUnderlineSingle
Do While .Execute("[a-zA-Z]{1,}", , , 1)
Set oRng = .Parent
oRng.Select
oRng.Collapse 0
n = n + 1
Loop
End With
MsgBox n
End Sub
Sub 要考查的词变下划线()
Dim Q As Range, R As Range
Set Q = IIf(Selection.Type = wdSelectionIP, ActiveDocument.Content, Selection.Range)
If Q = ActiveDocument.Content Then
K = MsgBox("要进行全文处理吗?", vbYesNoCancel + vbQuestion, "全文处理判断")
If K <> vbYes Then Exit Sub
End If
Set R = Q.Duplicate
With Q.Find
.Font.ColorIndex = wdRed
Do While .Execute("[a-zA-Z0-9]{1,}", , , 1)
If Not Q.InRange(R) Then Exit Do
n = n + 1
With Q
l = (7 - Len(n)) \ 2
.Text = Space$(l) & n & Space$(l)
.Collapse 0
End With
Loop
End With
End Sub
|
|