|
- Sub 选定内容转表格_waifa()
- '代码仅供参考,无后续修改服务,不挤面条。有其他需求请自己修改或AI,否则就付费定制!
- Dim rg As Range, rgt As Range, ta As Table, ce As Cell, sha As InlineShape
- Dim mydoc As Document, pa As Paragraph
- Set mydoc = ActiveDocument
- Set rg = Selection.Range
- Set rgt = rg.Paragraphs.First.Range
- rgt.InsertBefore vbNewLine
- Set ta = rgt.Tables.Add(rgt.Paragraphs.First.Range, 1, 2)
- ta.Columns(1).Width = rgt.Sections(1).PageSetup.TextColumns(1).Width / 3
- ta.Columns(2).Width = rgt.Sections(1).PageSetup.TextColumns(1).Width * 2 / 3
- ta.Style = "网格型"
- ta.Range.Style = "正文"
- ta.Range.Paragraphs.Last.Next.Range.InsertParagraphBefore
- rg.Start = ta.Range.End
- rg.Start = rg.Paragraphs(2).Range.Start
- Set rgt1 = rg.Paragraphs(1).Range
- Do
- If rgt1.End > rg.End Then Exit Do
- Set rgt1 = rgt1.Paragraphs.Last.Range
- If rgt1.ParagraphFormat.OutlineLevel < 4 Then
- If Len(ta.Cell(ta.Rows.Count, 2).Range.Text) > 2 Then ta.Rows.Add
- ta.Cell(ta.Rows.Count, 1).Range.FormattedText = rgt1
- Else
- If rgt1.Information(12) Then
- Set rgt1 = rgt1.Tables(1).Range
- Set rgt = ActiveDocument.Range(ta.Cell(ta.Rows.Count, 2).Range.End - 1, ta.Cell(ta.Rows.Count, 2).Range.End - 1)
- rgt.FormattedText = rgt1
- rgt1.Start = ta.Range.Paragraphs.Last.Next.Range.Start
- Else
- Set rgt = ActiveDocument.Range(ta.Cell(ta.Rows.Count, 2).Range.End - 1, ta.Cell(ta.Rows.Count, 2).Range.End - 1)
- rgt.FormattedText = rgt1
- End If
- End If
- Loop While rgt1.MoveEnd(4)
- With ta.Range.ParagraphFormat
- .Alignment = wdAlignParagraphLeft
- .CharacterUnitFirstLineIndent = 0
- .FirstLineIndent = 0
- .LeftIndent = 0
- End With
- rg.Delete
- MsgBox "OK"
- End Sub
复制代码 |
评分
-
3
查看全部评分
-
|