Solved

Sizing columns within tables and creating an macro to increment each row by one

Posted on 2008-10-29
4
586 Views
Last Modified: 2011-10-19
Hello,

  I have a few issues with tables within Microsoft's Word (primarily 2003). When I create a table and size the columns to a specific size they will eventually adjust, but I don't want them to. So now I have a bunch of tables were the columns are not uniformed which they need to be. Also, I have tried creating a macro that will go through the first column row by row creating a step number {1, 2, 3, etc..}, but I can't get it to work correctly. So my questions are

1) Once I set the columns to the size I desire how do I get word not to auto adjust them?
2) I created a macro to change the size of the columns, but it does not work and I have not idea why. The macro is listed below.
3) Does anyone know of a macro that will go through each row of the first column in table an create auto incrementing step count? Sort like Row 1 = 1,  Row 2 = Row 1 + 1,  Row 3 = Row 2 + 1


Here is my macro that I created: Also, I would like the macro to move the table so that is start from a specific location from the left edge {e.g., 0.8 in).

Sub SetTableColWidth()

  Selection.Tables(1).PreferredWidthType = wdPreferredWidthPoints
  Selection.Tables(1).PreferredWidth = InchesToPoints(8.86)
 
  Selection.Tables(1).Columns(1).Select
  Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
  Selection.Columns.Width = InchesToPoints(0.51)
 
  Selection.Tables(1).Columns(2).Select
  Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
  Selection.Columns.Width = InchesToPoints(3.49)
 
  Selection.Tables(1).Columns(3).Select
  Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
  Selection.Columns.Width = InchesToPoints(1.98)

  Selection.Tables(1).Columns(4).Select
  Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
  Selection.Columns.Width = InchesToPoints(1.98)
 
  Selection.Tables(1).Columns(5).Select
  Selection.Columns.PreferredWidthType = wdPreferredWidthPoints
  Selection.Columns.Width = InchesToPoints(0.9)
 
End Sub

Any help is greatly appreciated!!

Mark

0
Comment
Question by:LordHog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
dlc110161 earned 200 total points
ID: 22833890
The part you are missing, is setting the table to AutoFit - Fixed Column Width.

All you should need to do is set the table to Fixed column width. Add the following lines of code just above your End Sub.

Dawn Crosier-Bleuel
Word MVP
    Selection.Tables(1).Select
    Selection.Tables(1).AutoFitBehavior (wdAutoFitFixed)
    Selection.Tables(1).AutoFitBehavior (wdAutoFitFixed)

Open in new window

0
 

Author Comment

by:LordHog
ID: 22864767
Dawn,

  This does help, but Word still has a tendency to shift the table sizes around. I don't know why there just isn't an option to leave them static. Do you have to know how to perform the auto numbering for part three of the question? If so then I can award all the points.

Mark
0
 
LVL 19

Assisted Solution

by:dlc110161
dlc110161 earned 200 total points
ID: 22869733
Hi -

Have you tried selecting the column and then selecting Automatic Numbering? Or are you looking for something more complicated? See the attached image which shows two numbering schemes occuring at the same time.

Dawn Crosier-Bleuel
Word MVP
11-3-2008-12-44-04-PM.gif
0
 

Author Closing Comment

by:LordHog
ID: 31511082
Brilliant, it didn't even occur to me to select the column then select Format | Bullets and Numbering, very easy!!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question