Reputation: 31
My goal is to copy a multiline formatted text from Word to an Excel worksheet into one single cell using a VBA macro.
Now I've got a multiline text which needs two cells.
This is my current code:
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
I would like to have the following:
Any ideas how I can handle this or any input?
Upvotes: 0
Views: 2868
Reputation: 514
Instead of
...
Selection.Copy
.Cells(1, 1).PasteSpecial xlPasteValues
...
Code
.Cells(1, 1).Value=Selection.text
Upvotes: 1