零基础自学VBA

Word VBA Tips(1):关于自动编号

2017-08-31  本文已影响13人  highsea

将word中自动编码的部分转化为纯数字格式

Sub ConvertAutoNumToTxt()
    ActiveDocument.Content.ListFormat.ConvertNumbersToText
End Sub

还可以更复杂一些,根据是否选择了文本来部分或全部处理

Sub ConvertAutoNumToTxt()
    If Selection.Type = wdSelectionIP Then
        ActiveDocument.Content.ListFormat.ConvertNumbersToText
        ActiveDocument.Content.Find.Execute FindText:="^t", replacewith:=" ", Replace:=wdReplaceAll
    Else
        Selection.Range.ListFormat.ConvertNumbersToText
        Selection.Find.Execute FindText:="^t", replacewith:=" ", Replace:=wdReplaceAll
    End If
End Sub

或者干脆都不要

Sub myRemoveAutoNumbers()
'去除所有的自动编号
'
    ActiveDocument.Content.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph
End Sub
上一篇 下一篇

猜你喜欢

热点阅读