Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Width of a table (Word 2000)

    Hi

    In Visual Basic for Word, how do you determine (and set) the width of a table? Do you have to do it column by column?

    Thanks
    Dale

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

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

    Re: Width of a table (Word 2000)

    The Table object as a whole has properties PreferredWidthType and PreferredWidth.

    PreferredWidthType can be set to values wdPreferredWidthAuto, wdPreferredWidthPercent and wdPreferredWidthPoints.
    If you set it to wdPreferredWidthPercent, you can set PreferredWidth to a number (percentage) between 1 and 100, and if you set it to wdPreferredWidthPoints, you can set it to a number of points (1 inch = 72 points).

    With ActiveDocument.Tables(1)
    .PreferredWidthType = wdPreferredWidthPercent
    .PreferredWidth = 50
    End With

    You can also set the AutoFitBehavior property. Its values are wdAutoFitContent (try to make the columns wide enough for their contents), wdAutoFitWindow (make the table fit between the page margins) and wdAutoFitFixed.

  4. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,498
    Thanks
    3
    Thanked 139 Times in 132 Posts

    Re: Width of a table (Word 2000)

    You can do it either way depending on whether the table width is controlled (either by % page width or by a fixed size)

    Turn on your macro recorder and do it in Word and then look at the code to see what gets recorded.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  5. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Width of a table (Word 2000)

    Thanks Hans and Andrew

    I haven't expressed myself clearly enough.

    I want to (a) determine the width of table #1, and then ([img]/forums/images/smilies/cool.gif[/img] make table #2 the same width. From what you've told me, I understand how I can do ([img]/forums/images/smilies/cool.gif[/img], but how do you do (a)?

    Thanks
    Dale

  6. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Width of a table (Word 2000)

    If both tables have the same number of columns, it is probably easiest to loop through the columns and make each column in table #2 the same width as the corresponding column in table #1, as you originally suggested.

  7. #6
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Width of a table (Word 2000)

    You can calculate the sum of the widths of all columnsin Table(1) and again for Table(2). If both values are not the same, you can adjust the width of one or more columns in Table(2).

Posting Permissions

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