WD2000: 5992 VBA error 
Author Message
 WD2000: 5992 VBA error

I'm trying to read through the columns in a table in an existing
Word document but when I try I get this error "Error 5992: Cannot
access individual columns in this collection because the table has
mixed cell widths." Of course the table has mixed cell widths, most
do! Here is the code I am using:

Dim mydoc As Document, fnt As Font, rang As Range
Dim i As Integer
Dim newdoc As Document, newrange As Range, s As String
Dim fontnum As Integer, fontfam As Integer
Dim oldfsize As Integer, oldfont As String
Dim oldbold As Boolean, olditalic As Boolean, oldul As Boolean
Dim oldrow As Integer
Dim qa As Boolean, widarr() As Variant, totcol As Integer
Dim tbl As Table, col As Column, myrow As Row, cel As cell
Dim c As Integer

On Error GoTo MyError

Stop
qa = False
Set mydoc = Documents.Open("VBAtest.doc") ' Open doc with Haworth
table.
Open "vbatest.txt" For Output As #2
s = "{page}<ff;5><fv;0><sz;10><tj;4>"
writeln (s)

c = 1 ' Get column widths
totcol = mydoc.Range.Tables(1).Columns.Count
Set tbl = mydoc.Range.Tables(1)

For i = 1 To tbl.Columns.Count
    col = tbl.Columns(i) ' 5992 error here <====== ***
    widarr(i - 1) = col.Width
    ReDim Preserve widarr(i + 1)
Next i

Anyone have any clues how to fix this? I'll try doing the same thing
a different way but I see no reason why this shouldn't work.
Chuck



Fri, 30 Apr 2004 22:34:11 GMT  
 WD2000: 5992 VBA error
Hi, Chenck,

I found a method to access the cells,
see codes as follows.
Hope this may be help.
I got this infomation from the help of
VAB, in the related item of help of "table" object.

good luck,

J.J.

--------------------------------------------------
    Set myTable = ActiveDocument.Tables(1)
    Set myRows = ActiveDocument.Tables(1).Rows
    Set myCols = ActiveDocument.Tables(1).Columns

    x = y = 0

    rowNum = myTable.Rows.Count
    colNum = myTable.Columns.Count

    For x = 1 To rowNum
        ActiveDocument.Tables(1).Cell(x, 1).Select
        Selection.SelectRow
        For Each myCell In Selection.Cells
            MsgBox myCell.Range.Text & ", (" &
myCell.Range.Information(wdEndOfRangeRowNumber) & _
                    "," & myCell.Range.Information
(wdEndOfRangeColumnNumber) & ")"
        Next myCell
        Selection.Collapse
    Next x
----------------------------------------------------

Quote:
>-----Original Message-----
>I'm trying to read through the columns in a table in an
existing
>Word document but when I try I get this error "Error
5992: Cannot
>access individual columns in this collection because the
table has
>mixed cell widths." Of course the table has mixed cell
widths, most
>do! Here is the code I am using:

>Dim mydoc As Document, fnt As Font, rang As Range
>Dim i As Integer
>Dim newdoc As Document, newrange As Range, s As String
>Dim fontnum As Integer, fontfam As Integer
>Dim oldfsize As Integer, oldfont As String
>Dim oldbold As Boolean, olditalic As Boolean, oldul As
Boolean
>Dim oldrow As Integer
>Dim qa As Boolean, widarr() As Variant, totcol As Integer
>Dim tbl As Table, col As Column, myrow As Row, cel As cell
>Dim c As Integer

>On Error GoTo MyError

>Stop
>qa = False
>Set mydoc = Documents.Open("VBAtest.doc") ' Open doc with
Haworth
>table.
>Open "vbatest.txt" For Output As #2
>s = "{page}<ff;5><fv;0><sz;10><tj;4>"
>writeln (s)

>c = 1 ' Get column widths
>totcol = mydoc.Range.Tables(1).Columns.Count
>Set tbl = mydoc.Range.Tables(1)

>For i = 1 To tbl.Columns.Count
>    col = tbl.Columns(i) ' 5992 error here <====== ***
>    widarr(i - 1) = col.Width
>    ReDim Preserve widarr(i + 1)
>Next i

>Anyone have any clues how to fix this? I'll try doing the
same thing
>a different way but I see no reason why this shouldn't
work.
>Chuck

>.



Sat, 01 May 2004 09:49:43 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. WD2000 Error Message

2. Can not save document in WD2000

3. PPT97 and WD2000

4. WD2000: All Wizards fail, VBE does not appear to start:

5. WD95 underline in WD2000 problem

6. scroll speed of mouse selection in WD2000

7. WD2000 : Revision Bar Print Problem.

8. Code cleaner problems, WD2000

9. WD2000 vs. WD2002 openfile

10. WD2000: AutoCorrect doesn't always work


 
Powered by phpBB® Forum Software © phpBB Group