Table Column Width

Discussion in 'Word VBA' started by Pam, Nov 25, 2008.

  1. Pam

    Pam Guest

    I have a table in Word 2007 in which I want the first column to be 1 inch and
    the second column to be 5.5 inches. I tried recording the keystrokes, but I
    get this error: Run-time error 5992: Cannot access individual columns in
    this collection because the table has mixed cell widths. I can't get the
    columns to be two separate widths. Can you help?
     
    Pam, Nov 25, 2008
    #1
    1. Advertisements

  2. Pam

    Helmut Weber Guest

    Hi Pam,

    >I have a table in Word 2007 in which I want the first column to be 1 inch and
    >the second column to be 5.5 inches. I tried recording the keystrokes, but I
    >get this error: Run-time error 5992: Cannot access individual columns in
    >this collection because the table has mixed cell widths. I can't get the
    >columns to be two separate widths. Can you help?


    You may try:

    Sub Test699()
    Dim oRow As Row
    Dim oTbl As Table
    Set oTbl = ActiveDocument.Tables(1)
    With oTbl
    For Each oRow In oTbl.Range.Rows
    oRow.Cells(1).Width = InchesToPoints(1)
    oRow.Cells(2).Width = InchesToPoints(5.5)
    Next
    End With
    End Sub

    The reasons, why a seemably uniform table,
    that is, has equally wide cells in it's columns,
    are endless and to a good deal unknown.

    But accessing a row's cells collection,
    usually works well.

    --

    Greetings from Bavaria, Germany

    Helmut Weber, MVP WordVBA

    Vista Small Business, Office XP
     
    Helmut Weber, Nov 25, 2008
    #2
    1. Advertisements

  3. Pam

    Pam Guest

    That worked great. Thank you so much!

    Pam

    "Helmut Weber" wrote:

    > Hi Pam,
    >
    > >I have a table in Word 2007 in which I want the first column to be 1 inch and
    > >the second column to be 5.5 inches. I tried recording the keystrokes, but I
    > >get this error: Run-time error 5992: Cannot access individual columns in
    > >this collection because the table has mixed cell widths. I can't get the
    > >columns to be two separate widths. Can you help?

    >
    > You may try:
    >
    > Sub Test699()
    > Dim oRow As Row
    > Dim oTbl As Table
    > Set oTbl = ActiveDocument.Tables(1)
    > With oTbl
    > For Each oRow In oTbl.Range.Rows
    > oRow.Cells(1).Width = InchesToPoints(1)
    > oRow.Cells(2).Width = InchesToPoints(5.5)
    > Next
    > End With
    > End Sub
    >
    > The reasons, why a seemably uniform table,
    > that is, has equally wide cells in it's columns,
    > are endless and to a good deal unknown.
    >
    > But accessing a row's cells collection,
    > usually works well.
    >
    > --
    >
    > Greetings from Bavaria, Germany
    >
    > Helmut Weber, MVP WordVBA
    >
    > Vista Small Business, Office XP
    >
     
    Pam, Nov 25, 2008
    #3
  4. Pam

    maddy01 Guest

    Helmut Weber wrote on 11/25/2008 12:16 ET
    > Hi Pam
    >
    >> I have a table in Word 2007 in which I want the first column to be 1 inch an
    >> the second column to be 5.5 inches. I tried recording the keystrokes, but
    >> get this error: Run-time error 5992: Cannot access individual columns i
    >> this collection because the table has mixed cell widths. I can't get th
    >> columns to be two separate widths. Can you help
    >>
    >>

    >
    > You may try
    >
    > Sub Test699(
    > Dim oRow As Ro
    > Dim oTbl As Tabl
    > Set oTbl = ActiveDocument.Tables(1
    > With oTb
    > For Each oRow In oTbl.Range.Row
    > oRow.Cells(1).Width = InchesToPoints(1
    > oRow.Cells(2).Width = InchesToPoints(5.5
    > Nex
    > End Wit
    > End Su
    >
    > The reasons, why a seemably uniform table
    > that is, has equally wide cells in it's columns
    > are endless and to a good deal unknown
    >
    > But accessing a row's cells collection
    > usually works well
    >
    >
    > Greetings from Bavaria, German
    >
    > Helmut Weber, MVP WordVB
    >
    > Vista Small Business, Office X
    >

    Hi Helmut
    I too was having the same problem as Pam and tried your suggestion but th
    problem is that this way i have to change width for each individual cell.
    hav
    a large data table and thus would appreciate if you can suggest any othe
    alternative.
     
    maddy01, Jul 13, 2013
    #4
  5. Pam

    Stefan Blom Guest

    Since this newsgroup gets less attention these days, you may want to repost
    in the programming forum in the Microsoft Community:

    http://answers.microsoft.com/en-us/office/forum/customize?tab=all

    --
    Stefan Blom
    Microsoft Word MVP




    "maddy01" <> wrote in message
    news:...
    > Helmut Weber wrote on 11/25/2008 12:16 ET :
    >> Hi Pam,
    >>
    >>> I have a table in Word 2007 in which I want the first column to be 1
    >>> inch and
    >>> the second column to be 5.5 inches. I tried recording the keystrokes,
    >>> but I
    >>> get this error: Run-time error 5992: Cannot access individual columns
    >>> in
    >>> this collection because the table has mixed cell widths. I can't get
    >>> the
    >>> columns to be two separate widths. Can you help?
    >>>
    >>>

    >>
    >> You may try:
    >>
    >> Sub Test699()
    >> Dim oRow As Row
    >> Dim oTbl As Table
    >> Set oTbl = ActiveDocument.Tables(1)
    >> With oTbl
    >> For Each oRow In oTbl.Range.Rows
    >> oRow.Cells(1).Width = InchesToPoints(1)
    >> oRow.Cells(2).Width = InchesToPoints(5.5)
    >> Next
    >> End With
    >> End Sub
    >>
    >> The reasons, why a seemably uniform table,
    >> that is, has equally wide cells in it's columns,
    >> are endless and to a good deal unknown.
    >>
    >> But accessing a row's cells collection,
    >> usually works well.
    >>
    >>
    >> Greetings from Bavaria, Germany
    >>
    >> Helmut Weber, MVP WordVBA
    >>
    >> Vista Small Business, Office XP
    >>

    > Hi Helmut,
    > I too was having the same problem as Pam and tried your suggestion but the
    > problem is that this way i have to change width for each individual cell.
    > I
    > have
    > a large data table and thus would appreciate if you can suggest any other
    > alternative.
     
    Stefan Blom, Jul 15, 2013
    #5
  6. Tks.

    Douglas Salazar
    @dodo_salazar

    Em segunda-feira, 15 de julho de 2013 16h34min19s UTC-3, Stefan Blom escreveu:
    > Since this newsgroup gets less attention these days, you may want to repost
    >
    > in the programming forum in the Microsoft Community:
    >
    >
    >
    > http://answers.microsoft.com/en-us/office/forum/customize?tab=all
    >
    >
    >
    > --
    >
    > Stefan Blom
    >
    > Microsoft Word MVP
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > "maddy01" <> wrote in message
    >
    > news:...
    >
    > > Helmut Weber wrote on 11/25/2008 12:16 ET :

    >
    > >> Hi Pam,

    >
    > >>

    >
    > >>> I have a table in Word 2007 in which I want the first column to be 1

    >
    > >>> inch and

    >
    > >>> the second column to be 5.5 inches. I tried recording the keystrokes,

    >
    > >>> but I

    >
    > >>> get this error: Run-time error 5992: Cannot access individual columns

    >
    > >>> in

    >
    > >>> this collection because the table has mixed cell widths. I can't get

    >
    > >>> the

    >
    > >>> columns to be two separate widths. Can you help?

    >
    > >>>

    >
    > >>>

    >
    > >>

    >
    > >> You may try:

    >
    > >>

    >
    > >> Sub Test699()

    >
    > >> Dim oRow As Row

    >
    > >> Dim oTbl As Table

    >
    > >> Set oTbl = ActiveDocument.Tables(1)

    >
    > >> With oTbl

    >
    > >> For Each oRow In oTbl.Range.Rows

    >
    > >> oRow.Cells(1).Width = InchesToPoints(1)

    >
    > >> oRow.Cells(2).Width = InchesToPoints(5.5)

    >
    > >> Next

    >
    > >> End With

    >
    > >> End Sub

    >
    > >>

    >
    > >> The reasons, why a seemably uniform table,

    >
    > >> that is, has equally wide cells in it's columns,

    >
    > >> are endless and to a good deal unknown.

    >
    > >>

    >
    > >> But accessing a row's cells collection,

    >
    > >> usually works well.

    >
    > >>

    >
    > >>

    >
    > >> Greetings from Bavaria, Germany

    >
    > >>

    >
    > >> Helmut Weber, MVP WordVBA

    >
    > >>

    >
    > >> Vista Small Business, Office XP

    >
    > >>

    >
    > > Hi Helmut,

    >
    > > I too was having the same problem as Pam and tried your suggestion but the

    >
    > > problem is that this way i have to change width for each individual cell.

    >
    > > I

    >
    > > have

    >
    > > a large data table and thus would appreciate if you can suggest any other

    >
    > > alternative.
     
    Douglas Salazar, Aug 25, 2013
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Alex St-Pierre

    Adjust column width in table

    Alex St-Pierre, Mar 30, 2006, in forum: Word VBA
    Replies:
    1
    Views:
    157
    Jezebel
    Mar 30, 2006
  2. Diamonds_Mine

    Word 2003 Code to Change Table Column Width

    Diamonds_Mine, Jun 20, 2006, in forum: Word VBA
    Replies:
    1
    Views:
    117
    Cindy Meister
    Jun 20, 2006
  3. jbc

    Formatting column width

    jbc, Jul 30, 2006, in forum: Word VBA
    Replies:
    1
    Views:
    95
    Helmut Weber
    Jul 30, 2006
  4. NJ

    Fixed Column Width

    NJ, Aug 18, 2006, in forum: Word VBA
    Replies:
    1
    Views:
    101
    Cindy M.
    Aug 19, 2006
  5. NJ

    Protected Column Width

    NJ, Aug 21, 2006, in forum: Word VBA
    Replies:
    1
    Views:
    80
    Jean-Guy Marcil
    Aug 21, 2006
  6. Harry Kable

    Minimum column width in Word table

    Harry Kable, Oct 28, 2008, in forum: Word VBA
    Replies:
    2
    Views:
    1,839
    Harry Kable
    Oct 28, 2008
  7. Edward

    Table column width

    Edward, Feb 6, 2009, in forum: Word VBA
    Replies:
    2
    Views:
    120
    Edward
    Feb 7, 2009
  8. Jewel
    Replies:
    0
    Views:
    305
    Jewel
    Jan 13, 2014
Loading...