VBA将Word中的多行文本复制到Excel单元格中
我的目标是使用VBAmacros将多行格式的文本从Word复制到Excel工作表中。
现在我有一个需要两个单元格的多行文本。
这是我现在的代码:
With oWB.Worksheets("EPICS") ' Insert DESCRIPTION - todo ' ' HEADING xyz is selected, move one down and go to Pos1 Selection.MoveDown Unit:=wdLine, Count:=1 Selection.HomeKey Unit:=wdLine ' Save current line number (BEGIN) BeginText = Selection.Range.Information(wdFirstCharacterLineNumber) ' Go to the first table and one move up Selection.GoTo What:=wdGoToTable, Which:=wdGoToNext, Count:=1, Name:="" Selection.MoveUp Unit:=wdLine, Count:=1 ' Save current line number (END) EndText = Selection.Range.Information(wdFirstCharacterLineNumber) RangeToSelect = EndText - BeginText Selection.MoveUp Unit:=wdLine, Count:=RangeToSelect, Extend:=wdExtend Selection.Copy .Cells(1, 1).PasteSpecial xlPasteValues End With
这创build了以下内容:
我想有以下几点:
任何想法如何处理这个或任何input?
代替
...
Selection.Copy
.Cells(1, 1).PasteSpecial xlPasteValues
...
码
.Cells(1, 1).Value=Selection.text