R
Rick
I'm trying to insert a table in Word at the end of a
document. I want to add text in the cells of the first
row, format the width and then add data from a database
to the rows below it. (I can get the data) The table with
the correct # of rows is created at the end of the
document but Selection.Tables(TblIndex).Cell(1, 1).Select
gives me an error that the requested member of the
collection does not exist. The cursor is in the first
cell after table creation. If I remove this line of code,
Quantity is inserted but the cursor will not advance to
the next cell.
How can this be fixed? I'm using Word 98 and Word XP
CODE:
NumRows = NumRows + 3
ActiveDocument.Tables.AddSelection.Range,_
NumRows,4 '4 is the number of columns
TblIndex = ActiveDocument.Tables.Count
Selection.Tables(TblIndex).Cell(1, 1).Select
Selection.TypeText "Quantity"
Selection.Tables(TblIndex).Cell(1, 1).Width =
InchesToPoints(0.75)
Selection.Tables(TblIndex).Cell(1, 2).Select
Selection.TypeText "Description"
Selection.Tables(TblIndex).Cell(1, 2).Width =
InchesToPoints(3.5)
Selection.Tables(TblIndex).Cell(1, 3).Select
Selection.TypeText "Price Each"
Selection.Tables(TblIndex).Cell(1, 3).Width =
InchesToPoints(1)
Selection.Tables(TblIndex).Cell(1, 4).Select
Selection.TypeText "Ext. Price"
Selection.Tables(TblIndex).Cell(1, 4).Width =
InchesToPoints(1)
Selection.Tables(TblIndex).Rows(1).Shading.Texture =
wdTexture10Percent
document. I want to add text in the cells of the first
row, format the width and then add data from a database
to the rows below it. (I can get the data) The table with
the correct # of rows is created at the end of the
document but Selection.Tables(TblIndex).Cell(1, 1).Select
gives me an error that the requested member of the
collection does not exist. The cursor is in the first
cell after table creation. If I remove this line of code,
Quantity is inserted but the cursor will not advance to
the next cell.
How can this be fixed? I'm using Word 98 and Word XP
CODE:
NumRows = NumRows + 3
ActiveDocument.Tables.AddSelection.Range,_
NumRows,4 '4 is the number of columns
TblIndex = ActiveDocument.Tables.Count
Selection.Tables(TblIndex).Cell(1, 1).Select
Selection.TypeText "Quantity"
Selection.Tables(TblIndex).Cell(1, 1).Width =
InchesToPoints(0.75)
Selection.Tables(TblIndex).Cell(1, 2).Select
Selection.TypeText "Description"
Selection.Tables(TblIndex).Cell(1, 2).Width =
InchesToPoints(3.5)
Selection.Tables(TblIndex).Cell(1, 3).Select
Selection.TypeText "Price Each"
Selection.Tables(TblIndex).Cell(1, 3).Width =
InchesToPoints(1)
Selection.Tables(TblIndex).Cell(1, 4).Select
Selection.TypeText "Ext. Price"
Selection.Tables(TblIndex).Cell(1, 4).Width =
InchesToPoints(1)
Selection.Tables(TblIndex).Rows(1).Shading.Texture =
wdTexture10Percent