|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
* 楼主,请将附件示例文档中的“想得到的效果如下”及以后的文字删除,保存后;
* 选定要处理的文字范围,应用下面的宏:
- Sub aaaa下划线_提取句子到文末_随机排列()
- Dim r As Range, s As Range, n&, t$
- With Selection
- If .Type = 1 Then MsgBox "Not-Select!", 0 + 16: End
- If .Text Like "*" & vbCr & vbCr Then .Characters.Last.Delete
- If .Paragraphs.Last.Range.End < ActiveDocument.Content.End Then
- If .Next.Text = vbCr Then .Next.Delete
- End If
- With Selection
- Set r = .Range
- Set s = .Range
- End With
- With r.Find
- .ClearFormatting
- .Text = ""
- .Font.Underline = wdUnderlineSingle
- .Forward = True
- .MatchWildcards = True
- Do While .Execute
- With .Parent
- n = n + 1
- t = t & "/" & .Text
- .Text = Space(3) & n & Space(3)
- .SetRange Start:=.End, End:=s.End
- End With
- Loop
- End With
- End With
-
- With ActiveDocument.Content
- .InsertAfter Text:=vbCr & vbCr & t
- .Paragraphs.Last.Range.Select
- End With
- With Selection
- .Find.Execute "/", , , 0, , , , , , "^p", 2
- .MoveStart
- .ConvertToTable Separator:=wdSeparateByParagraphs, NumColumns:=1, AutoFitBehavior:=wdAutoFitFixed
- .Tables(1).Style = "网格型"
- .InsertColumnsRight
- .Tables(1).Select
- .Tables(1).AutoFitBehavior (wdAutoFitWindow)
- .Tables(1).Columns(2).Select
- Dim c As Cell
- For Each c In .Cells
- c.Range.Text = Rnd()
- Next
- .Tables(1).Select
- .Sort ExcludeHeader:=False, FieldNumber:="列 2", SortFieldType:= _
- wdSortFieldNumeric, SortOrder:=wdSortOrderAscending, FieldNumber2:="", _
- SortFieldType2:=wdSortFieldSyllable, SortOrder2:=wdSortOrderAscending, _
- FieldNumber3:="", SortFieldType3:=wdSortFieldSyllable, SortOrder3:= _
- wdSortOrderAscending, Separator:=wdSortSeparateByCommas, SortColumn:= _
- False, CaseSensitive:=False, LanguageID:=wdSimplifiedChinese, _
- SubFieldNumber:="段落数", SubFieldNumber2:="段落数", SubFieldNumber3:="段落数"
- .Tables(1).Columns(2).Delete
- .Tables(1).Select
- .Rows.ConvertToText Separator:=wdSeparateByParagraphs, NestedTables:=False
- End With
- With Selection
- .Previous(4, 1).Delete
- .Next(4, 1).Delete
- End With
- ' Stop
- With ListGalleries(wdNumberGallery).ListTemplates(1).ListLevels(1)
- .NumberFormat = "%1."
- .TrailingCharacter = wdTrailingTab
- .NumberStyle = wdListNumberStyleUppercaseLetter
- .NumberPosition = CentimetersToPoints(0)
- .Alignment = wdListLevelAlignLeft
- .TextPosition = CentimetersToPoints(0.74)
- .TabPosition = wdUndefined
- .ResetOnHigher = 0
- .StartAt = 1
- .LinkedStyle = ""
- End With
- ListGalleries(wdNumberGallery).ListTemplates(1).Name = ""
- Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
- ListGalleries(wdNumberGallery).ListTemplates(1), ContinuePreviousList:= _
- False, ApplyTo:=wdListApplyToSelection, DefaultListBehavior:= _
- wdWord10ListBehavior
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|