Consulting

Results 1 to 4 of 4

Thread: Text within Table

  1. #1

    Text within Table

    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.

  2. #2
    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.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    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.

  4. #4
    What then would determine which piece of text goes in which cell? Look at the Word built-in process for converting text to tables.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •