楼主的问题,使我想起曾经有个网友问,对于WORD中的段落重新进行了手工编号,能否按照手工编号重新组合段落的问题。 在WROD中要排序必须要使用表格。 楼主的问题(前提是一个段落)假如放在EXCEL中的随机数产生则更方便,然后选择性粘贴然后排序后返回至WORD中;如果使用WORD,处理的思路是这样的,在每个段落(每道题)之前插入随机数和分隔符,将文字转换为表格, 根据随机数进行排序,删除第一列,再将表格转换为文字。 以下是代码供参考: Sub Ri()
Dim i As Paragraph
For Each i In ActiveDocument.Paragraphs
i.Range.InsertBefore Rnd() & ";"
Next
Selection.WholeStory
Selection.ConvertToTable Separator:=wdSeparateByDefaultListSeparator, _
NumColumns:=2, NumRows:=10, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "网格型"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
End With
ActiveDocument.Tables(1).Select
Selection.Sort ExcludeHeader:=False, FieldNumber:="列 1", SortFieldType:= _
wdSortFieldNumeric, SortOrder:=wdSortOrderAscending, FieldNumber2:="", _
SortFieldType2:=wdSortFieldAlphanumeric, SortOrder2:=wdSortOrderAscending _
, FieldNumber3:="", SortFieldType3:=wdSortFieldAlphanumeric, SortOrder3:= _
wdSortOrderAscending, Separator:=wdSortSeparateByCommas, SortColumn:= _
False, CaseSensitive:=False, LanguageID:=wdEnglishUK, SubFieldNumber:= _
"段落数", SubFieldNumber2:="段落数", SubFieldNumber3:="段落数"
ActiveDocument.Tables(1).Columns(1).Delete
ActiveDocument.Tables(1).Select
Selection.Rows.ConvertToText Separator:=wdSeparateByParagraphs, _
NestedTables:=False
End Sub
|