这仅仅是合并,如果需要在此基础上,将文章段落自动编号如何实现,总不能手动输吧?其实这个小编也想到了,利用VBA宏可以帮助你实现文章自动编号。切换到“开发工具”(注:如没有,请打开文件—选项—自定义功能区,勾选右侧栏中的“开发工具”)选项卡,点击“宏”,输入名称并点击创建,例如“手动编号变自动编号”。
复制以下代码到VBA编辑器,如图所示,完毕后退出即可(PC登录微信,进入订阅号找到我们,点击查看历史消息并复制本文内代码,或在公众号界面输入“合并”直接获取下载地址)。
Sub 手动编号变自动编号() Dim myRange As Range If Selection.Type = wdSelectionIP Then Selection.WholeStory Set myRange = Selection.Range With ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1) .NumberFormat = "%1." .TrailingCharacter = wdTrailingTab .NumberStyle = wdListNumberStyleArabic .NumberPosition = CentimetersToPoints(1.98) .Alignment = wdListLevelAlignLeft .TextPosition = CentimetersToPoints(2.72) .TabPosition = CentimetersToPoints(2.72) .ResetOnHigher = 0 .StartAt = 1 .LinkedStyle = "" End With ListGalleries(wdNumberGallery).ListTemplates(1).Name = "" Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _ wdNumberGallery).ListTemplates(1), ContinuePreviousList:=False, ApplyTo:= _ wdListApplyToWholeList, DefaultListBehavior:=wdWord10ListBehavior myRange.Select Dim i As Paragraph For Each i In Selection.Paragraphs i.Range.Characters(1).Select Do While Selection.Characters.Last Like "#" Selection.MoveEnd unit:=wdCharacter, Count:=1 Loop If Selection Like "*[、..]" Then Selection.Delete myRange.Select Next Selection.ParagraphFormat.TabStops.ClearAll ActiveDocument.DefaultTabStop = CentimetersToPoints(0.19) With Selection.ParagraphFormat .LeftIndent = CentimetersToPoints(0.74) .FirstLineIndent = CentimetersToPoints(-0.74) End With End Sub 使用的时候,还是点击开发工具选项卡中的“宏”选中“手动编号变自动编号”,点击运行即可。如果只是某一个段落需要自动编号,可以圈选要编号的文档内容再进行操作就可以了。 |