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

将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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容