1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Word 2003 - change column widths in a table - help!

Discussion in 'Business Applications' started by BECA, Dec 6, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. BECA

    BECA Thread Starter

    Joined:
    Dec 6, 2011
    Messages:
    2
    (I am reposting retroboy17's question, since I went to answer it and this forum had closed the thread due to inactivity.)
    Hey everyone,
    I am only familiar with the basics in Word (I am a bit better with Excel) but I have encountered a problem that I am hoping for some help with at work: I am handed over a Word 2003 document every monday morning that is roughly 5-9 pages long that consists of roughly 5-7 tables on it. All 6 tables have 6 columns with identical headings for each. Every Monday, I spend a lot of time making these into the exact same format, adjusting column widths to the exact same specs. I created a macro to make all of my adjustments but it fails when it comes time to adjust the column widths for all the tables. I would like to be able to run a macro with the columns widths to finish as follows:

    column 1: .73
    column 2: .35
    column 3: .66
    column 4: .51
    column 5: .38
    column 6: 7.56

    Please help me get to the bottom of this to save my Mondays!
    Thanks!
     
  2. BECA

    BECA Thread Starter

    Joined:
    Dec 6, 2011
    Messages:
    2
    From what I’ve seen, Word 2003 doesn’t let you iterate through columns like you would in Word 2007. So, when writing this as a 2003 macro, you have to brute force it. This has worked for me (this assumes that you have already set the table width to the sum of all of these columns):

    Dim t As Table
    For Each t In ActiveDocument.Tables
    t.Cell(1, 1).Select

    Selection.Expand Unit:=wdColumn
    Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
    Selection.Columns.PreferredWidth = InchesToPoints(0.73)
    Selection.MoveRight Unit:=wdCharacter, Count:=1

    Selection.Expand Unit:=wdColumn
    Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
    Selection.Columns.PreferredWidth = InchesToPoints(0.35)
    Selection.MoveRight Unit:=wdCharacter, Count:=1

    Selection.Expand Unit:=wdColumn
    Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
    Selection.Columns.PreferredWidth = InchesToPoints(0.66)
    Selection.MoveRight Unit:=wdCharacter, Count:=1

    Selection.Expand Unit:=wdColumn
    Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
    Selection.Columns.PreferredWidth = InchesToPoints(0.51)
    Selection.MoveRight Unit:=wdCharacter, Count:=1

    Selection.Expand Unit:=wdColumn
    Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
    Selection.Columns.PreferredWidth = InchesToPoints(0.38)
    Selection.MoveRight Unit:=wdCharacter, Count:=1

    Selection.Expand Unit:=wdColumn
    Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
    Selection.Columns.PreferredWidth = InchesToPoints(7.56)
    Selection.MoveRight Unit:=wdCharacter, Count:=1

    Next t
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1030023