Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Resize First Column in Table (Word 2003)

    I would like to create a macro that resizes the first column in a table. The catch is I have documents that are around 50 pages. Most pages have tables but some do not. I would like something that goes from page to page, checks for a table, if there is one - resizes the first column and goes to the next page, if there is no table just goes to the next page until it has checked the entire document.

    Is something like this possible?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Resize First Column in Table (Word 2003)

    The following macro will change the width of the first column in each table in the active document to 1.5 inches (you can change this value as needed):

    Sub ResizeFirstCol()
    Dim t As Table
    For Each t In ActiveDocument.Tables
    t.Columns(1).Width = InchesToPoints(1.5)
    Next t
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resize First Column in Table (Word 2003)

    Thanks Hans but I get the following run time error.

    Cannot access individual columns in this collection because the table has mixed cell widths.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Resize First Column in Table (Word 2003)

    In that case, you have to loop through the individual cells in the first column of each table.
    <code>
    Sub ResizeFirstCol()
    Dim t As Table
    Dim i As Integer
    For Each t In ActiveDocument.Tables
    For i = 1 To t.Rows.Count
    t.Cell(i, 1).Width = InchesToPoints(1.5)
    Next i
    Next t
    End Sub</code>

Posting Permissions

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