PDA

View Full Version : Text within Table



VB-AN-IZ
12-19-2015, 06:43 PM
I'm trying to create a macro that will allow me to paste text into a table, while maintaining the cells' dimensions regardless of where the text fits or does not fit into each cell; I just want the text to spread through the table as if it wasn't there.

The table would contain:

- 1 column
- 100 rows
- 2 lines per row
- 36 characters per line; 72 character per row (Arial font size 12, right indentation 34.65cm, 150% zoom)

At this point, I'm not even sure if it's best to paste the text into a table, or to create a table after the text is pasted.

The best I've come up with is a border, which is heflpul but not sufficient for what I'm trying to do:


Selection.WholeStory
Selection.ClearFormatting
ActiveDocument.Range.Font.Color = wdColorBlack
ActiveDocument.Range.Style = "No Spacing"
ActiveDocument.Range.Font.Name = "Arial"
ActiveDocument.Range.Font.Size = "12"
ActiveDocument.Range.Font.Bold = True
ActiveDocument.ShowSpellingErrors = True
ActiveDocument.ShowGrammaticalErrors = True
Options.CheckSpellingAsYouType = True

Next myStoryRange
With Selection.ParagraphFormat
.RightIndent = CentimetersToPoints(23.65)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.CharacterUnitRightIndent = 0
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
End With
Selection.HomeKey Unit:=wdStory
End Sub


Any help is much appreciated.

gmayor
12-19-2015, 11:07 PM
Each cell of your table is a separate range so pasting as you describe is not possible. You may be able to paste the text to the document and convert the text to a table from the Insert Table dropdown. Much depends on what the text is.

VB-AN-IZ
12-20-2015, 09:50 PM
It'd just be plain text; no colors or formatting.

It would actually be easier if the macro converted the text into a table, rather than pasting text into a table and then applying a macro.

gmayor
12-21-2015, 02:29 AM
What then would determine which piece of text goes in which cell? Look at the Word built-in process for converting text to tables.