vbastringms-wordword-2010

How can I copy text from a Word 2010 table into a VBA string, maintaining line breaks?


I've got a table in Word with a cell with a few short lines in. I want to copy the contents of that cell into a .txt file, maintining the line breaks.

Currently the line breaks are lost: Contents of Word table cell:

Alice
Bob

Contents of VBA String:

AliceBob

Code sample to get string:

MyString = ActiveDocument.Tables(a).Cell(1, 1).Range.Text

Solution

  • I solved my problem by using copy & paste into a new word document, then saving the new document as a text file. Not neat or tidy, but effective enough for the situation.