一、原表格以及转移出来的文本
转为纯文本时,每一行内容保留表头,文本在表格下方
二、代码
Sub 表格转为纯文本()Dim t As Singlet = TimerDim i As Integer, j As IntegerDim ta As TableDim arr() As StringSet ta = ActiveDocument.Range.Tables(1)ReDim arr(1 To ta.Rows.count, 1 To ta.Columns.count)For i = 1 To ta.Rows.countFor j = 1 To ta.Columns.countarr(i, j) = ta.cell(i, j).Range.Textarr(i, j) = Left(arr(i, j), Len(arr(i, j)) - 2)NextNextta.SelectWith Selection.MoveRight Unit:=wdCharacter, count:=1, Extend:=wdMoveFor i = 2 To ta.Rows.countFor j = 1 To ta.Columns.count.Range.Text = arr(1, j) & ":" & vbCr.EndKey Unit:=wdStory, Extend:=wdMove.Range.Text = arr(i, j).EndKey Unit:=wdStory, Extend:=wdMove.TypeParagraphNextNextEnd WithMsgBox "运行时间(秒):" & Timer - t
End Sub