Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Search Search
Search for:
Tech Support Guy > > >

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


(!)

BECA's Avatar
BECA BECA is offline
Junior Member with 2 posts.
THREAD STARTER
 
Join Date: Dec 2011
Experience: Intermediate
06-Dec-2011, 07:28 PM #1
Solved: Word 2003 - change column widths in a table - help!
(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!
BECA's Avatar
BECA BECA is offline
Junior Member with 2 posts.
THREAD STARTER
 
Join Date: Dec 2011
Experience: Intermediate
06-Dec-2011, 07:30 PM #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

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


Tags
columns, macro, tables, word

(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑

Content Relevant URLs by vBSEO 3.3.2