Error creating rows with columns having different column width 
Author Message
 Error creating rows with columns having different column width

I get a Run time error 5991 "cannot access individual columns in this
collection because the table has mixed cell widths" when I try to run
the macro to create rows with columns having different column width.
here is the code. Can anyone please help me?

Sub CreateTable()
'
' CreateTable Macro
' Macro recorded 07.01.2003 by System Integration
'
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1,
NumColumns:= _ 3, DefaultTableBehavior:=wdWord9TableBehavior,
AutoFitBehavior:= _
        wdAutoFitFixed
    Selection.Tables(1).AllowAutoFit = False ' i tried this after i
searched for this error in net, but no use
    Selection.Tables(1).Columns(1).PreferredWidthType =
wdPreferredWidthPoints ' this one works neither!
    Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=26.7,
RulerStyle:= _
        wdAdjustNone
    Selection.Tables(1).Columns(3).SetWidth ColumnWidth:=149.25,
RulerStyle:= _
        wdAdjustNone
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend
    Selection.Font.Size = 9
    Selection.MoveDown Unit:=wdLine, Count:=1
End Sub



Sat, 25 Jun 2005 16:41:17 GMT  
 Error creating rows with columns having different column width
Hi PT,

The code woks fine ... as long as the cursor is not at the bottom of a table
that has different column widths.

HTH


Quote:
> I get a Run time error 5991 "cannot access individual columns in this
> collection because the table has mixed cell widths" when I try to run
> the macro to create rows with columns having different column width.
> here is the code. Can anyone please help me?

> Sub CreateTable()
> '
> ' CreateTable Macro
> ' Macro recorded 07.01.2003 by System Integration
> '
>     ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1,
> NumColumns:= _ 3, DefaultTableBehavior:=wdWord9TableBehavior,
> AutoFitBehavior:= _
>         wdAutoFitFixed
>     Selection.Tables(1).AllowAutoFit = False ' i tried this after i
> searched for this error in net, but no use
>     Selection.Tables(1).Columns(1).PreferredWidthType =
> wdPreferredWidthPoints ' this one works neither!
>     Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=26.7,
> RulerStyle:= _
>         wdAdjustNone
>     Selection.Tables(1).Columns(3).SetWidth ColumnWidth:=149.25,
> RulerStyle:= _
>         wdAdjustNone
>     Selection.EndKey Unit:=wdLine, Extend:=wdExtend
>     Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend
>     Selection.Font.Size = 9
>     Selection.MoveDown Unit:=wdLine, Count:=1
> End Sub



Sun, 26 Jun 2005 21:33:38 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Multi Column TextBox Column Widths

2. *** ListView Items on one row - different columns

3. *** ListView Items on one row - different columns

4. FlexGrid Merge Columns: Row/Column selection inconsistant?!?!

5. Setting datagrid column width sets width of toplevel!!

6. Set Grid width to sum of Column Widths

7. ListView column width = ListView width ?

8. Total width of columns = Width of ListView

9. Total width of columns = Width of ListView

10. Make dbgrid columns width follow form width ???

11. Total width of columns = Width of ListView

12. Total width of columns = Width of ListView

 

 
Powered by phpBB® Forum Software