My first problem is with mail merge. I have created a a Data File and a table, yet I am not able to fill my table with information from my Data File. The << just seems to be inserted after wherever the cursor is on the page, which is not where the table is. All that is entered into the actual table is a '59'. Therefore I think I either need to to change the code or be able to move the cursor. Here is the code I am currently using:
wrdDoc.Tables.Add(wrdSelection.Range, ADOTable1.FieldCount, 3);
wrdDoc.Tables.Item(1).Columns.Item(1).SetWidth(51,wdAdjustNone);
wrdDoc.Tables.Item(1).Columns.Item(2).SetWidth(20,wdAdjustNone);
wrdDoc.Tables.Item(1).Columns.Item(3).SetWidth(100,wdAdjustNone);
// Set the shading on the first row to light gray
wrdDoc.Tables.Item(1).Rows.Item(1).Cells
.Shading.BackgroundPatternColorIndex := wdGray25;
// BOLD the first row
wrdDoc.Tables.Item(1).Rows.Item(1).Range.Bold := True;
// Center the text in Cell (1,1)
wrdDoc.Tables.Item(1).Cell(1,1).Range.Paragraphs.Alignment :=
wdAlignParagraphCenter;
// Fill each row of the table with data
wrdDoc.Tables.Item(1).Cell(1, 1).Range.InsertAfter('Time');
wrdDoc.Tables.Item(1).Cell(1, 2).Range.InsertAfter('');
wrdDoc.Tables.Item(1).Cell(1, 3).Range.InsertAfter('Teacher');
For Count := 1 to (ADOTable1.FieldCount - 1) do
begin
wrdDoc.Tables.Item(1).Cell((Count + 1), 1).Range.InsertAfter(wrdSelection.Range,'Time' + IntToStr(Count));
wrdDoc.Tables.Item(1).Cell((Count + 1), 2).Range.InsertAfter(wrdSelection.Range,'THonorific' + IntToStr(Count));
wrdDoc.Tables.Item(1).Cell((Count + 1), 3).Range.InsertAfter(wrdSelection.Range,'TSurname' + IntToStr(Count));
end;
My second problem is that I do not know what the correct SQL syntax is for editing the name of a column in the database (I am using Delphi 7 and Microsoft Jet Engine if that makes a difference).
The third problem is that when I add a new column to my database manually (which I need to do) I get a 'violation' error in one of my units when I activate an ADOTable. This only happens on one unit and it happens when I add a column with any name anywhere in the table. I know that is vague but I can't seem to narrow down the problem any further than that.
If you could help with me with any of those it would be great. Thanks.