I have some Delphi code that selects a bookmark in Word and then creates a table. My problem is that there is a title at the top of the page that when I select the range also gets selected and when my table is created the title is overwritten. How can I just select the range after my bookmark to add my table so that my title is preserved?
R := WordApp.ActiveDocument.Bookmarks.Item('bmStartSecond').Range;
R.Select;
TableFormat(WordDoc, intCounter + 10);
function TableFormat(Adocument : variant; intNumRows : integer): variant;
var
wrdSelection: variant;
begin
wrdSelection := WordApp.Selection;
Adocument.Tables.Add(Range:=wrdSelection.Range, NumRows:=intNumRows, NumColumns:=3);
Adocument.Tables.Item(1).Columns.Item(1).SetWidth(InchestoPoint(2.5),0);
Adocument.Tables.Item(1).Columns.Item(2).SetWidth(InchestoPoint(2.25),0);
Adocument.Tables.Item(1).Columns.Item(3).SetWidth(InchestoPoint(2.75),0);
wordDoc.Tables.Item(1).Cell(Row:=1, Column:= 1).Range.Text := 'Offense:';
wordDoc.Tables.Item(1).Cell(Row:=1, Column:= 2).Range.Text := 'Date & Place:';
wordDoc.Tables.Item(1).Cell(Row:=1, Column:= 3).Range.Text := 'Disposition:';
TableFormat := Adocument;
end;
Thanks, Leslie