View Single Post
 
Old 08-31-2017, 03:13 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,387
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That's a bit like trying to unscramble an omelette. All you're outputting to Excel is the text of each cell, with none of its formatting. And, if a cell in Word contains a paragraph break or manual line break, any content after it will be output with those breaks removed. Consequently, anything you write back to the tables from Excel cannot be guaranteed to restore either the original formatting or content. If that's not a concern, I suggest you spend a little time studying how the code you posted works - there's only one line in it you'd need to change to reverse the process:
Cells(resultRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
should become:
.Cell(iRow, iCol).Range.Text = Cells(resultRow, iCol)

Finally, kindly don't start multiple threads on the same topic; I've deleted the other one.

PS: When posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote